x.var <- seq(0, 50, 1)
probs <- dbinom(x.var, 50, .1667)
plot(x.var, probs, type = "h")

Question 1

x.var <- seq(0, 60, 1)
probs <- dbinom(x.var, 60, .5)
plot(x.var, probs, type = "h")

Question 2

qbinom(p = .05, 60, .5)
## [1] 24

24 asparagus pee smelling people would give you p<.05.

Question 3

 set.seed(33002176)
rbinom(n = 1, 60, .4)
## [1] 26

Based on my answer to Question 2, I would not reject the null hypothesis in favor of the alternative that the true proportion of asparagus-pee-smellers is less than 50%.

Question 4

set.seed(33002176)
rbinom(n = 100, 60, .4)
##   [1] 26 24 26 21 20 24 31 24 24 25 28 23 28 28 27 26 27 27 23 23 20 22 27 26 21
##  [26] 15 31 24 28 25 25 23 27 26 24 28 20 18 24 23 28 23 24 29 25 26 22 17 26 18
##  [51] 16 23 25 28 28 29 25 28 23 19 25 32 26 26 27 17 23 29 20 20 21 24 27 22 26
##  [76] 24 27 27 24 19 27 23 28 24 27 21 27 22 23 18 21 25 22 27 27 26 26 27 22 28

Out of this sample of 100, I would reject 18. I believe you would call the situation where you do not reject the null hypothesis a “type 1 error.”

Question 5

set.seed(33002176) 
x.var <- seq(0, 180, 1)
probs <- dbinom(x.var, 180, .4)
plot(x.var, probs, type = "h")

set.seed(33002176) 
rbinom(n = 100, 180, .4)
##   [1] 70 76 82 77 72 76 69 75 63 81 79 74 68 81 78 71 74 71 78 62 80 78 80 81 71
##  [26] 70 69 75 74 66 61 68 70 67 74 79 70 73 75 71 70 82 70 75 75 73 78 67 90 63
##  [51] 80 70 66 86 79 69 74 78 74 83 73 77 79 79 69 67 78 67 57 76 69 69 70 78 72
##  [76] 59 75 74 74 72 85 65 71 65 68 69 76 76 71 73 61 77 68 81 76 72 61 69 81 77

I would reject 12 out of 100 from the null hypothesis. I am surprised by the outcome because most of the numbers are very close together.

Question 6

The moral here about the role of sample size in null hypothesis significance testing is that the study is not affected by the fact that one person may have never had asparagus and another does eat it.

Question 7

x.var <- seq(0, 60, 1)
probs <- dbinom(x.var, 60, .4)
plot(x.var, probs, type = "h")

Question 8

qbinom(p = .05,60, .4)
## [1] 18

Question 9

set.seed(33002176)
rbinom(n = 1, 60, .4)
## [1] 26

Based on my answer to Question 9, I would not reject the null hypothesis in favor of the alternative that the true proportion of asparagus-pee-smellers is less than 50%.

Question 10

set.seed(33002176)
rbinom(n = 100, 100, .4)
##   [1] 44 43 39 32 33 41 43 31 42 38 30 45 44 37 34 46 42 40 46 43 37 47 30 46 47
##  [26] 33 40 40 39 45 42 36 36 37 39 48 42 47 40 43 40 39 34 39 43 43 31 41 45 37
##  [51] 37 33 39 37 50 43 47 38 43 35 41 34 47 48 46 37 46 37 44 39 50 39 40 34 49
##  [76] 43 44 42 42 49 36 46 40 38 40 39 36 45 40 41 44 38 29 45 40 37 38 35 41 34

I rejected the null hypothesis 40% of the time. They would be considered a type 1 error.

Question 11

I expected to reject the null hypthesis about 60% of the time because of the past lines of codes and the equations.