Objectives: Use R to compute sample sizes needed and power for a given significance level and alternative hypothesis in the ANOVA setting.
Reading: Supplemental notes (below); Devore pages 420-426. May be helpful to review lesson 9.
Notes:
Recall in an ANOVA we test the hypotheses about the true averages of several populations, for example,
H0: μ1=μ2=μ3
Ha: at least two of them are different.Further, recall from lesson nine that determining sample size depended on specifying:
- Significance level (alpha) desired
- The effect size - in other words how much a true difference do we want to detect
- The power desired - the probability we correctly identify the the effect when it exists
Devore presents one method of specifying the effect size (see the Biometrika paper from which he reproduced his power curves). There are other approaches. In R, this is made (in my opinion) relatively simple.
As in the two sample case, R has a built in function to compute sample size or power in ANOVA: "power.anova.test". Understanding how to use the function is best done using a simple example.
Suppose for the null/alternative hypothesis above we are comparing three types of tires, and want to have 0.9 power of detecting that one tire type has mean tread life 3000 miles different from the other two (with usual significance level of .05).
Further, suppose we know that the standard deviation of tread life is 2000: this is saying the (true) "within" variance is 20002=4000000.
The other quantity we need is the "between" group variance. Just write down three true mean tread lives where one differs from the other two by 3000 and find the variance of the three numbers. For example, both of the following are three means with one 3000 different than the other two:
> var(c(0,0,3000))
[1] 3e+06
> var(c(40000,40000,43000))
[1] 3e+06Now we have all quantities needed by the function to compute the desired sample size (note the default for "sig" is 0.05):
> power.anova.test( groups=3, betw=3000000, with=4000000, power=.9)
Balanced one-way analysis of variance power calculation
groups = 3
n = 9.516354
between.var = 3e+06
within.var = 4e+06
sig.level = 0.05
power = 0.9
NOTE: n is number in each groupThe result is we need 9.52 tires in each group - obviously, a fractional tire is pretty meaningless so we should round up (more conservative) and obtain 10 of each tire type.
As a final note, the same function is also useful if one wants to know the power obtained for a given sample size. In that case, the "power=" option is left out and the option "n=" included. Thus we could determine the power sample sizes of 9 and 10 would achieve to see if we really need to round up.
Suggested Problem:
For the tire example above, calculate the power for samples of size 9 and 10. Change the desired power from 0.9 to 0.95 - how does this affect the sample size? Now change the effect size from detecting a single difference of 3000 to only 2000 - what does that do to the necessary sample size?
Back to LTC Sturdivant's Home Page