rm(list = ls())
x.var <- seq(0, 60, 1)
probs <- dbinom(x.var, 60, .5)
plot(x.var, probs, type = "h")
qbinom(p = .05, 60, .5)
## [1] 24
set.seed(33377932)
rbinom(n = 1, 60, .5)
## [1] 31
I would not reject the null hypothesis that the proportion of asparagus pee smellers is 50% because the last code that we ran gave us the p-value and it is greater than the significance number needed to be lower than to reject the null hypothesis.
set.seed(33377932)
rbinom(n = 100, 60, .5)
## [1] 31 31 24 29 33 26 24 30 30 29 29 35 22 28 28 38 35 27 28 32 28 31 29 27 31
## [26] 31 22 34 32 36 31 35 30 30 32 27 24 26 28 27 34 32 28 30 36 33 38 29 27 33
## [51] 31 33 29 25 35 28 27 25 31 28 32 29 34 34 30 22 37 26 29 21 31 34 26 36 30
## [76] 30 33 32 28 31 31 26 29 32 30 31 34 33 27 24 26 28 33 32 25 28 30 30 26 39
Out of the 100 samples, you would have to reject the null hypothesis 8 times. In cases where you do not reject the null hypothesis but it is false it is called a type II error. I was a little surprised at how low the number of rejections was.
x.var <- seq(0, 180, 1)
probs <- dbinom(x.var, 180, .5)
plot(x.var, probs, type = "h")
qbinom(p = .05, 180, .5)
## [1] 79
set.seed(33377932)
rbinom(n = 100, 180, .4)
## [1] 69 68 77 64 75 82 62 70 69 63 63 71 64 79 67 63 79 66 62 74 68 74 77 64 66
## [26] 72 77 60 72 73 74 75 68 74 80 72 78 71 71 70 74 66 74 79 64 67 61 76 74 68
## [51] 71 79 76 64 57 65 75 75 75 73 74 64 63 74 77 79 78 62 66 81 72 68 73 64 77
## [76] 78 71 81 84 71 65 66 60 68 72 77 73 76 65 80 73 70 70 68 73 90 76 75 67 69
Out of 100 times, you would reject the null hypothesis 93 times. You fail to reject it 7 times.
The moral about the role of sample size in null hypothesis significance testing is that smaller sample sizes lead to less rejection of the null hypothesis and larger sample sizes increase the amount of rejections significantly.
x.var <- seq(0, 60, 1)
probs <- dbinom(x.var, 60, .4)
plot(x.var, probs, type = "h")
qbinom(p = .05, 60, .4)
## [1] 18
8 few asparagus pee smellers out of 60 people corresponds to p<.05.
set.seed(33377932)
rbinom(n = 1, 60, .4)
## [1] 25
set.seed(33377932)
rbinom(n = 100, 60, .4)
## [1] 25 19 25 19 23 22 25 21 23 23 24 19 18 36 22 26 22 27 24 23 24 23 15 20 25
## [26] 17 22 18 27 28 28 25 19 25 24 20 29 24 27 24 24 30 25 26 22 15 18 26 26 28
## [51] 24 23 20 18 20 25 19 17 27 22 25 20 20 28 23 27 24 24 26 27 29 28 27 29 24
## [76] 24 22 25 21 23 26 26 28 25 24 28 24 28 26 19 26 29 32 15 25 21 21 22 28 23
You reject the null hypothesis 67 times. When you reject the null hypothesis and it is actually true it is called a type I error.
I expected to reject the null hypothesis less because we now know that the null hypothesis is true. In the first sample of 100 that we tested the rejections were a lot higher because we were just testing what we thought was the percentage of asparagus pee smellers so I expected the rejections to be less knowing the actual percentage.