What can happen:
| Decision | ||
|---|---|---|
| Truth | Do not reject | Reject null |
| Null true | Correct | Type I error |
| Null false | Type II error | Correct |
Tension between truth and decision about truth (imperfect).
[1] 14.487469 5.014611 6.924277 5.201860 8.852952
[6] 10.835874 3.686684 11.165242 8.016188 12.383518
[11] 1.378099 3.172503 13.074996 11.353573 5.015575
x from population with mean 10 or not (over):
One Sample t-test
data: x
t = -1.8767, df = 14, p-value = 0.08157
alternative hypothesis: true mean is not equal to 10
95 percent confidence interval:
5.794735 10.280387
sample estimates:
mean of x
8.037561
List of 10
$ statistic : Named num -1.88
..- attr(*, "names")= chr "t"
$ parameter : Named num 14
..- attr(*, "names")= chr "df"
$ p.value : num 0.0816
$ conf.int : num [1:2] 5.79 10.28
..- attr(*, "conf.level")= num 0.95
$ estimate : Named num 8.04
..- attr(*, "names")= chr "mean of x"
$ null.value : Named num 10
..- attr(*, "names")= chr "mean"
$ stderr : num 1.05
$ alternative: chr "two.sided"
$ method : chr "One Sample t-test"
$ data.name : chr "x"
- attr(*, "class")= chr "htest"
rowwise to work one random sample at a timeWe correctly rejected 422 times out of 1000, so the estimated power is 0.422.
power.t.test. Input delta is difference between null and true mean:| Method | Power |
|---|---|
| Simulation | 0.422 |
power.t.test |
0.4378 |
n=, replaced by a power=:
One-sample t test power calculation
n = 33.3672
delta = 2
sd = 4
sig.level = 0.05
power = 0.8
alternative = two.sided
Try a sample size and see what power you get. Here’s \(n = 15\) from before:
To get power 0.80, two-sided, need a bigger sample.
How much bigger? No idea. Make any guess. What about \(n = 50\)?
Power now too big.
sample size between 15 and 50, say \(n = 30\):
Now a little too small, hence right answer between 30 and 50, closer to 30.
… simulation has randomness: limit to how close you can get.
Rule of thumb: with 1000 simulations, estimated power within 0.03 (3%).
power.t.test a collection (“vector”) of values, it will do calculation for each one.
One-sample t test power calculation
n = 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
delta = 2
sd = 4
sig.level = 0.05
power = 0.2928286, 0.5644829, 0.7539627, 0.8693979, 0.9338976, 0.9677886, 0.9847848, 0.9929987, 0.9968496, 0.9986097
alternative = two.sided
List of 8
$ n : num [1:10] 10 20 30 40 50 60 70 80 90 100
$ delta : num 2
$ sd : num 4
$ sig.level : num 0.05
$ power : num [1:10] 0.293 0.564 0.754 0.869 0.934 ...
$ alternative: chr "two.sided"
$ note : NULL
$ method : chr "One-sample t test power calculation"
- attr(*, "class")= chr "power.htest"
[1] 0.2928286 0.5644829 0.7539627 0.8693979 0.9338976
[6] 0.9677886 0.9847848 0.9929987 0.9968496 0.9986097
[1] 0.94908647 0.99956360 0.88277128 0.99619287
[5] 0.77070660 0.97770385 0.61513033 0.91115700
[9] 0.43784659 0.75396272 0.27216777 0.51028173
[13] 0.14530058 0.26245348 0.06577280 0.09719303
[17] 0.02500000 0.02500000
pulling things from the right places:
delta is true difference in meanspower.t.test, so take as 14.
Comments
mean=10, that is, the true mean equals the null mean, \(H_0\) is actually true, and the probability of rejecting it then is \(\alpha = 0.05\).