Professional Documents
Culture Documents
power
power
power
Yibi Huang
Chapter 7 - 1
Power & Sample Size Calculation
Chapter 7 - 2
Errors and Power in Hypothesis Testing
I A Type I error occurs when H0 is true but is rejected.
I A Type II error occurs when H0 is false but is accepted.
I The (significance) level of a test is the chance of making a
Type I error, i.e., the chance to reject a H0 when it is true.
I The power of the test is the the chance of rejecting H0 when
Ha is true:
power = 1 − P(making type II error|H0 is false) = 1 − β
= P(correctly reject H0 |H0 is false)
I A good test should have small test-level and large power.
Ha is rejected H0 is rejected
(H0 is accepted) (Ha is accepted)
√
H0 is true α = P(Type I error)
√
H0 is false β = P(Type II error)
Chapter 7 - 3
Power Calculation for ANOVA
For a CRD design with g treatments, recall
the means model: yij = µi + εij
and the effects model: yij = µ + αi + εij ,
for i = 1, . . . , g , and j = 1, . . . , ni .
The two models are related via the relationship
µi = µ + α i .
For CRDs, we use the means model more often. However, for
power and sample size calculation, we need to use the effects
model and µ must be defined as
g ni g
1 XX 1 X
µ= µi = ni µ i .
N N
i=1 j=1 i=1
Pg Pg
which implies that i=1 ni αi = 0. Here N = i=1 ni is the total
number of experimental units.
Chapter 7 - 4
Recall the H0 and Ha for the ANOVA F test are
To find P(F > Fα, g −1, N−g ), we must know the distribution of F .
I What is the distribution of F under H0 ? Fg −1,N−g .
I And under Ha ?
Chapter 7 - 5
MSTrt SSTrt /(g − 1)
For F = = , recall in Ch3 we’ve shown that
MSE SSE/(N − g )
I no matter under H0 or Ha , it is always true that
SSE
∼ χ2N−g , and E(MSE) = σ 2
σ2
I For the numerator, SSTrt /σ 2 has a χ2g −1 distribution under
H0 . But under Ha , it has a non-central Chi-square
distribution χ2g −1,δ with non-central parameter
Pg 2
i=1 ni αi
δ= .
σ2
Moreover, Xg
E(SSTrt ) = (g − 1)σ 2 + ni αi2
i=1
| {z }
δσ 2
(
(g − 1)σ 2 under H0
=
(g − 1 + δ)σ 2 under Ha
Chapter 7 - 6
Non-Central F -Distribution
Under Ha , it can be shown that
MSTrt
F =
MSE
has a non-central F -distribution on degrees of freedom g − 1
and N − g , with non-centrality parameter δ, denoted as
Pg
ni α2
F ∼ Fg −1,N−g ,δ where δ = i=12 i .
σ
Recall that
g ni g
1 XX 1 X
αi = µi − µ, and µ = µi = ni µi .
N N
i=1 j=1 i=1
H0: F ∼ F4,20
0.4
Ha: F ∼ F4,20,21.25
0.0
0 5 10 15
Chapter 7 - 9
Example 1: Power Calculation (3)
The critical value to reject H0 keeping the significance level at
α = 0.05 is F0.05,4,20 ≈ 2.866.
> qf(0.05,4,20, lower.tail=F)
[1] 2.866081
Accept H0 Reject H0
0.4
Area = 0.05
0.0
0 F0.05,4,20 5 10 15
Accept H0 Reject H0
0.4
Power
0.0
0 F0.05,4,20 5 10 15
Chapter 7 - 11
Example 1: Power Calculation (5)
Remark
The power of a test is not a single value, but a function of the
parameters in Ha . If parameter µi ’s change their values, the power
of the test also changes. It makes no sense to talk about the power
of a test without specifying the parameters in Ha
Chapter 7 - 12
Power Of A Test Is Affected By ...
Chapter 7 - 13
Example 2: Sample Size Calculation (1)
I g = 5 treatment groups of equal sample size ni = n for all i
I assume σ = 0.8
I desired significance level α = 0.05
I Assuming the design is balanced that all groups have identical
sample size n, what is the minimal sample size n per
treatment to have power 0.95 when
α1 = 0.5, α2 = −0.5, α3 = 1, α4 = −1, α5 = 0?
Solution. The non-centrality parameter is
Pg
ni α2 n
δ = i=12 i = [0.52 + (−0.5)2 + 12 + (−1)2 + 02 ]
σ 0.82
n
= × 2.5 = 3.9n
0.82
So
(
MSTrt Fg −1, N−g = F4, 5n−5 under H0
F = ∼
MSE Fg −1, N−g ,δ = F4, 5n−5, 3.9n under Ha
Chapter 7 - 14
Recall the critical value F ∗ for rejecting H0 at level α = 0.05 is
F ∗ = Fα, g −1, N−g = F0.05, 4, 5n−5
which can be find in R via the command
> F.crit = qf(alpha, g-1, N-g, lower.tail=F) # syntax
> F.crit = qf(0.05, 4, 5*n-5, lower.tail=F) # sub-in the values
By definition,
Power = P(reject H0 |Ha is true)
= P(the non central F statistic ≥ F ∗ )
= P(F (g − 1, N − g , δ) ≥ F ∗ )
= P(F (4, 5n − 5, 3.9n) ≥ F ∗ )
which can be found in R via the command
> pf(F.crit, g-1, N-g, ncp=delta, lower.tail=F) # syntax
> pf(F.crit, 4, 5*n-5, ncp=3.9*n, lower.tail=F) # sub-in values
> n = 5
> F.crit = qf(0.05, 4, 5*n-5, lower.tail=F)
> pf(F.crit, 4, 5*n-5, ncp=3.9*n, lower.tail=F)
[1] 0.8994675 # less than 0.95, not high enough
> n = 6
> F.crit = qf(0.05, 4, 5*n-5, lower.tail=F)
> pf(F.crit, 4, 5*n-5, ncp=3.9*n, lower.tail=F)
[1] 0.9578791 # greater than 0.95, bingo!
I You could repeat the sample size calculations for various levels
of σ to see how it affects the needed sample size.
Chapter 7 - 17
How to Specify the Ha ?
As the power of a test depends on the alternative hypothesis Ha ,
that is, the αi ’s, one might has to try several sets of αi ’s to find
the appropriate sample size. But how many Ha ’s we have to try?
Chapter 7 - 18
Power and Sample Size Calculation for Complete Block Designs
For complete block designs
Chapter 7 - 20
Non-Centrality Parameter for Balanced Factorial Designs
Chapter 7 - 21
E.g., consider a a × b × c factorial design with r replicates per
treatment
Chapter 7 - 24