Section 46 Statistical Power: Example

46.1 power.t.test
The function power.t.test
computes the power of the one- or two- sample t test, or determine parameters to obtain a target power.
?power.t.test
power.t.test(n = NULL, delta = NULL, sd = 1, sig.level = 0.05,
power = NULL,
type = c("two.sample", "one.sample", "paired"),
alternative = c("two.sided", "one.sided"),
strict = FALSE, tol = .Machine$double.eps^0.25)
46.2 Sample size calculation: Two-sample t test
We wish to compare treatment A with treatment B, i.e. compare their means, where a two-sample t-test is appropriate.
The standard deviation for both treatments is approximately 4.
Level of significance: Type I error (\(\large \alpha\)): p = 0.05, that is the probability of concluding there is a difference when in fact there is no difference between A and B, is 0.05.
Mean difference: \(\large \delta\) = 5, i.e. we wish to detect a true difference between means of A and B as 5 unit
Power of test: 1- Type II error (\(\large 1 - \beta\)) = 0.80, i.e. we want the Power of the test to be 0.80.
Calculation of Sample Size
power.t.test(n = NULL, delta = 5, sd = 4,
sig.level = 0.05, power = 0.80,
type = 'two.sample',
alternative = 'two.sided')
Two-sample t test power calculation
n = 11.09423
delta = 5
sd = 4
sig.level = 0.05
power = 0.8
alternative = two.sided
NOTE: n is number in *each* group
Conclusion
We need n = 11 samples for each treatment group (22 in total) to achieve 80% power detecting the mean difference of 5 units or more between treatment groups A and B.
Calculation of Statistical Power
power.t.test(n = 15, delta = 5, sd = 4,
sig.level = 0.05, power = NULL,
type = 'two.sample',
alternative = 'two.sided')
Two-sample t test power calculation
n = 15
delta = 5
sd = 4
sig.level = 0.05
power = 0.9104815
alternative = two.sided
NOTE: n is number in *each* group
Conclusion
An experiment conducted with n = 15 samples for each treatment group (30 in total) will have 91% power detecting the mean difference of 5 units or more between treatment groups A and B.