Week 6 & 7 - Analysis of Variance (WK 5 & 6)
Week 6 & 7 - Analysis of Variance (WK 5 & 6)
Analysis of Variance
Chap 11-1
Chapter Goals
Chap 11-4
One-Way Analysis of Variance
Assumptions
Populations are normally distributed
Chap 11-5
Completely Randomized Design
Chap 11-6
Hypotheses of One-Way ANOVA
H0 : μ1 μ2 μ3 μk
All population means are equal
i.e., no treatment effect (no variation in means among
groups)
HA : Not all of the population means are the same
At least one population mean is different
i.e., there is a treatment effect
Does not mean that all population means are different
(some pairs may be the same)
Chap 11-7
One-Factor ANOVA
H0 : μ1 μ2 μ3 μk
HA : Not all μi are the same
μ1 μ2 μ3
Chap 11-8
One-Factor ANOVA
(continued)
H0 : μ1 μ2 μ3 μk
HA : Not all μi are the same
or
μ1 μ2 μ3 μ1 μ2 μ3
Chap 11-9
Partitioning the Variation
Total variation can be split into two parts:
Chap 11-10
Partitioning the Variation
(continued)
Chap 11-11
Partition of Total Variation
Chap 11-12
Total Sum of Squares
i 1 j1
Where:
Response, X
Chap 11-14
Sum of Squares Between
i1
Where:
i1
SSB
Variation Due to
Differences Among Groups MSB
k 1
Mean Square Between =
SSB/degrees of freedom
mi mj
Chap 11-16
Between-Group Variation
(continued)
SSB n1 ( x1 x ) n2 ( x 2 x ) ... nk ( x k x )
2 2 2
Response, X
X3
X2 X
X1
i 1 j 1
Where:
k nj
SSW ( x ij x i )2
i 1 j 1
SSW
Summing the variation
MSW
within each group and then
adding over all groups Nk
Mean Square Within =
SSW/degrees of freedom
mi
Chap 11-19
Within-Group Variation
(continued)
Response, X
X3
X2
X1
Source of SS df MS F ratio
Variation
Between SSB MSB
SSB k-1 MSB =
Samples k - 1 F = MSW
Within SSW
SSW N-k MSW =
Samples N-k
SST =
Total N-1
SSB+SSW
k = number of populations
N = sum of the sample sizes from all populations
df = degrees of freedom
Chap 11-21
One-Factor ANOVA
F Test Statistic
H0: μ1= μ2 = … = μ k
HA: At least two population means are different
Test statistic
MSB
F
MSW
MSB is mean squares between variances
MSW is mean squares within variances
Degrees of freedom
df1 = k – 1 (k = number of populations)
df2 = N – k (N = sum of sample sizes from all populations)
Chap 11-22
Interpreting One-Factor ANOVA
F Statistic
The F statistic is the ratio of the between
estimate of variance and the within estimate
of variance
The ratio must always be positive
df1 = k -1 will typically be small
df2 = N - k will typically be large
Chap 11-24
One-Factor ANOVA Example:
Scatter Diagram
Distance
270
Club 1 Club 2 Club 3
254 234 200 260 •
••
263
241
218
235
222
197
250 X1
240 •
237 227 206 • ••
230
251 216 204
220
•
X2 • X
••
210
x1 249.2 x 2 226.0 x 3 205.8
•• X3
200 ••
x 227.0 190
1 2 3
Chap 11-25
Club
One-Factor ANOVA Example
Computations
Club 1 Club 2 Club 3 x1 = 249.2 n1 = 5
254 234 200 x2 = 226.0 n2 = 5
263 218 222
x3 = 205.8 n3 = 5
241 235 197
237 227 206 N = 15
x = 227.0
251 216 204 k=3
SSB = 5 [ (249.2 – 227)2 + (226 – 227)2 + (205.8 – 227)2 ] = 4716.4
SSW = (254 – 249.2)2 + (263 – 249.2)2 +…+ (204 – 205.8)2 = 1119.6
Critical Decision:
Value:
Reject H0 at = 0.05
F = 3.885
= .05 Conclusion:
There is evidence that
0 Do not Reject H0 at least one μi differs
reject H0 F = 25.275
F.05 = 3.885 from the rest Chap 11-27
ANOVA -- Single Factor:
Excel Output
EXCEL: tools | data analysis | ANOVA: single factor
SUMMARY
Groups Count Sum Average Variance
Club 1 5 1246 249.2 108.2
Club 2 5 1130 226 77.5
Club 3 5 1029 205.8 94.2
ANOVA
Source of
SS df MS F P-value F crit
Variation
Between
4716.4 2 2358.2 25.275 4.99E-05 3.885
Groups
Within
1119.6 12 93.3
Groups
Total 5836.0 14
Chap 11-28
The Tukey-Kramer Procedure
Tells which population means are significantly
different
e.g.: μ1 = μ2 μ3
Done after rejection of equal means in ANOVA
Allows pair-wise comparisons
Compare absolute mean differences with critical
range
μ1= μ2 μ3 x
Chap 11-29
Tukey-Kramer Critical Range
MSW 1 1
Critical Range q
2 ni n j
where:
q = Value from standardized range table
with k and N - k degrees of freedom for
the desired level of
MSW = Mean Square Within
ni and nj = Sample sizes from populations (levels) i and j
Chap 11-30
The Tukey-Kramer Procedure:
Example
1. Compute absolute mean
Club 1 Club 2 Club 3 differences:
254 234 200
263 218 222 x1 x 2 249.2 226.0 23.2
241 235 197 x1 x 3 249.2 205.8 43.4
237 227 206
251 216 204 x 2 x 3 226.0 205.8 20.2
4. Compare:
5. All of the absolute mean differences x1 x 2 23.2
are greater than critical range.
Therefore there is a significant x1 x 3 43.4
difference between each pair of
means at 5% level of significance. x 2 x 3 20.2
Chap 11-32
Tukey-Kramer in PHStat
Chap 11-33
Randomized Complete Block ANOVA
Chap 11-34
Partitioning the Variation
Total variation can now be split into three parts:
Chap 11-35
Sum of Squares for Blocking
Where:
Chap 11-37
Mean Squares
SSBL
MSBL Mean square blocking
b 1
SSB
MSB Mean square between
k 1
SSW
MSW Mean square within
(k 1)(b 1)
Chap 11-38
Randomized Block ANOVA Table
Source of SS df MS F ratio
Variation
Between MSBL
SSBL b-1 MSBL
Blocks MSW
Between MSB
SSB k-1 MSB
Samples MSW
Within
SSW (k–1)(b-1) MSW
Samples
MSBL
F= Blocking test: df1 = b - 1
MSW df2 = (k – 1)(b – 1)
Reject H0 if F > F
Chap 11-40
Main Factor Test
H0 : μ1 μ2 μ3 ... μk
HA : Not all population means are equal
MSB
F= Main Factor test: df1 = k - 1
MSW df2 = (k – 1)(b – 1)
Reject H0 if F > F
Chap 11-41
Example
Alarm type
Room 1 2 3 4
1 5.2 7.4 3.9 12.3
2 6.3 8.1 6.4 9.4
3 4.9 5.9 7.9 7.8
4 3.2 6.5 9.2 10.8
5 6.8 4.9 4.1 8.5
Chap 11-42
ANOVA
Source of P-
Variation SS df MS F value F crit
Rows 6.07 4 1.516 0.426 0.787 3.259
Columns 56.28 3 18.76 5.27 0.015 3.490
Total 105.06 19
Chap 11-43
Fisher’s
Least Significant Difference Test
To test which population means are significantly
different
e.g.: μ1 = μ2 ≠ μ3
Done after rejection of equal means in randomized
block ANOVA design
Allows pair-wise comparisons
Compare absolute mean differences with critical
range
m1= m2 m3 x
Chap 11-44
Fisher’s Least Significant
Difference (LSD) Test
2
LSD t /2 MSW
b
where:
t/2 = Upper-tailed value from Student’s t-distribution
for /2 and (k -1)(n - 1) degrees of freedom
MSW = Mean square within from ANOVA table
b = number of blocks
k = number of levels of the main factor
Chap 11-45
Fisher’s Least Significant
Difference (LSD) Test (continued)
2
LSD t /2 MSW
b
Compare:
Is x i x j LSD ? x1 x 2
Chap 11-47
Two-Way ANOVA
(continued)
Assumptions
Chap 11-48
Two-Way ANOVA
Sources of Variation
Chap 11-49
Two-Way ANOVA
Sources of Variation
(continued)
SSB
SST b–1
Variation due to factor B
Total Variation
SSAB
Variation due to interaction (a – 1)(b – 1)
between A and B
N-1
SSE N – ab
Inherent variation (Error)
Chap 11-50
Two Factor ANOVA Equations
i1 j1 k 1
i1
Sum of Squares
Interaction Between a b
A and B: SS AB n ( x ij x i x j x )2
i1 j1
i1 j 1 k 1
Chap 11-52
Two Factor ANOVA Equations
(continued)
a b n
where: x
i 1 j1 k 1
ijk
x Grand Mean
b n
abn
x
j1 k 1
ijk
x ijk
xj i1 k 1
Mean of each level of factor B
an
n x ijk
x ij
a = number of levels of factor A
Mean of each cell
k 1 n
b = number of levels of factor B
n’ = number of replications in each cell
Chap 11-53
Mean Square Calculations
SS A
MS A Mean square factor A
a 1
SSB
MSB Mean square factor B
b 1
SS AB
MS AB Mean square interaction
(a 1)(b 1)
SSE
MSE Mean square error
N ab
Chap 11-54
Two-Way ANOVA:
The F Test Statistic
F Test for Factor A Main Effect
H0: μA1 = μA2 = μA3 = • • •
MS A Reject H0
HA: Not all μAi are equal F
MSE if F > F
MSA MSA
Factor A SSA a–1
= SSA /(a – 1) MSE
MSB MSB
Factor B SSB b–1
= SSB /(b – 1) MSE
AB MSAB MSAB
SSAB (a – 1)(b – 1)
(Interaction) = SSAB / [(a – 1)(b – 1)] MSE
MSE =
Error SSE N – ab
SSE/(N – ab)
Total SST N–1
Chap 11-56
Features of Two-Way ANOVA
F Test
Degrees of freedom always add up
N-1 = (N-ab) + (a-1) + (b-1) + (a-1)(b-1)
Total = error + factor A + factor B + interaction
The denominator of the F Test is always the
same but the numerator is different
The sums of squares always add up
SST = SSE + SSA + SSB + SSAB
Total = error + factor A + factor B + interaction
Chap 11-57
Examples:
Interaction vs. No Interaction
Interaction is
No interaction:
present:
Factor B Level 1
Mean Response
Mean Response
Factor B Level 1
Factor B Level 3
Factor B Level 2
Factor B Level 2
Factor B Level 3