
440 11 ANOVA and Elements of Experimental Design
parameter λ. The quantity F
−1
(1 −α, k −1, N −k) is the 1 −α percentile
(a cut point for which the upper tail has a probability
α) of a standard
F-distribution with k
−1 and N −k degrees of freedom.
The interplay among the power, sample size, and effect size is illustrated
by the following example.
Example 11.8. Suppose k
=4 treatment means are to be compared at a signif-
icance level of
α =0.05. The experimenter is to decide how many replicates n
to run at each level, so that the null hypothesis is rejected with a probability
of at least 0.9 if f
2
=0.0625 or if
P
i
α
2
i
is equal to σ
2
/4.
For n
=60, i.e., N =240, the power is calculated in a one-line command:
1-ncfcdf(finv(1-0.05, 4-1, 4
*
(60-1)), 4-1, 4
*
(60-1), 15) %0.9122
Here we used λ = nk f
2
=60 ×4 ×0.0625 =15.
One can now try different values of n (group sample sizes) to achieve
the desired power; this change affects only two arguments in Eq. (11.5):
k(n
−1) and λ = nk f
2
. Alternatively, one can use MATLAB’s built in function
fzero(fun,x0) which tries to find a zero of fun near some initial value x0.
k=4; alpha = 0.05; f2 = 0.0625;
f = @(n) 1-ncfcdf( finv(1-alpha, k-1,k
*
n-k),k-1,k
*
n-k, n
*
k
*
f2 ) - 0.90;
ssize = fzero(f, 100) %57.6731
%Sample size of n=58 (per treatment) ensures the power of 90% for
%the effect size f^2=0.0625.
Thus, sample size of n = 58 will ensure the power of 90% for the specified
effect size. The function
fzero is quite robust with respect to specification of
the initial value; in this case the initial value was n
=100.
If we wanted to plot the power for different sample sizes (Fig. 11.7), the
following simple MATLAB script would do it. The inputs are the k number
of treatments and the significance level
α. The specific alternative H
1
is such
that
P
i
α
2
i
=σ
2
/4, so that λ = n/4.
k=4; %number of treatments
alpha = 0.05; %significance level
y=[]; %set values of power for n
for n=2:100
y =[y 1-ncfcdf(finv(1-alpha, k-1, k
*
(n-1)), ...
k-1, k
*
(n-1), n/4)];
end
plot(2:100, y,’b-’,’linewidth’,3)
xlabel(’Group sample size n’); ylabel(’Power’)
In the above analysis, the total sample size is N = k ×n =240.