Chapter 8
Analysis of variance
BB113 Statistics and its applications
May – Aug. 2019
Textbook: Chapter 11
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 1
Objectives
In this chapter, you learn:
◼ The basic concepts of experimental design.
◼ How to use one-way analysis of variance to test for differences
among the means of several groups.
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 2
Chapter Overview
DCOVA
Analysis of Variance (ANOVA)
Completely Randomized Design Two-Way
One-Way ANOVA ANOVA
F-test
F-test
Tukey-
Kramer
Multiple Interaction
Comparisons Effects
Levene Test
For
Homogeneity Tukey Multiple
of Variance Comparisons
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 3
What is ANOVA?
◼ Analysis of variance
◼ Statistical comparison among samples taken
from many populations
◼ Comparison – result of an experiment
◼ Example:
◼ the management try to find ways to improve sales of
mobile electronics items.
◼ They decided to try selling those items in 4 different
in-store location and then observe the sales
◼ Factor – in-store location
◼ Levels – the actual different locations
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 4
One-Way Analysis of Variance
DCOVA
Factor = shift # of levels = 3
◼ Examples: Levels = 1st shift, 2nd shift, 3rd shift.
◼ Number of accidents for 1st, 2nd, and 3rd shift.
◼ Expected mileage for five brands of tires.
Factor = tire brand # of levels = 5
Levels = Brand A, B, C, D & E.
◼ Assumptions:
◼ Populations are normally distributed.
◼ Populations have equal variances.
◼ Samples are randomly and independently
selected.
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 5
General ANOVA Setting
DCOVA
◼ Investigator controls one or more factors of interest.
◼ Each factor contains two or more levels.
◼ Levels can be numerical or categorical.
◼ Different levels produce different groups.
◼ Think of each group as a sample from a different
population.
◼ Observe effects on the dependent variable.
◼ Are the groups the same?
◼ Experimental design: the plan used to collect the data.
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 6
Example: 1 factor with 3 levels
Factor = anxiety
Numbers of level = 3 (low, moderate, high)
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 7
Completely Randomized Design
DCOVA
◼ Experimental units (subjects) are assigned
randomly to groups. All of the same or similar kind or nature
◼ Subjects are assumed homogeneous.
◼ it is made up of things (people, events, objects, etc.)
that are similar to each other.
◼ Only one factor or independent variable.
◼ With two or more levels.
◼ Analyzed by one-factor analysis of variance
(ANOVA).
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 8
Hypotheses of One-Way ANOVA
DCOVA
◼ 𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 ⋯ = 𝜇𝑐 # of groups = c
◼ All population means are equal.
◼ i.e., no factor effect (no variation in means among
groups.)
◼ 𝐻1 : Not all of the population means are equal
◼ At least one population mean is different.
◼ i.e., there is a factor effect.
◼ Does not mean that all population means are
different (some pairs may be the same).
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 9
One-Way ANOVA
DCOVA
𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 ⋯ = 𝜇𝑐
𝐻1 : Not all 𝜇𝑗 are equal
When The Null Hypothesis is True
All Means are the same:
(No Factor Effect)
μ1 = μ 2 = μ 3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 10
One-Way ANOVA (continued)
DCOVA
𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 ⋯ = 𝜇𝑐
𝐻1 : Not all 𝜇𝑗 are equal
When The Null Hypothesis is NOT true
At least one of the means is different.
(Factor Effect is present).
or
μ1 = μ2 μ3 μ1 μ2 μ3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 11
Partitioning the Variation
DCOVA
◼ Total variation can be split into two parts:
SST = SSA + SSW
SST = Total Sum of Squares
(Total variation).
SSA = Sum of Squares Among Groups
(Among-group variation).
SSW = Sum of Squares Within Groups
(Within-group variation).
To analyze variation towards the goal of determining possible differences
among the group means
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 12
Partitioning the Variation
(continued)
DCOVA
SST = SSA + SSW
Total Variation = the aggregate variation of the individual
data values across the various factor levels (SST).
Among-Group Variation = variation among the factor
sample means (SSA).
Within-Group Variation = variation that exists among
the data values within a particular factor level (SSW).
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 13
Partition of Total Variation
DCOVA
Total Variation (SST)
Variation Due to Variation Due to Random
= Factor (SSA) + Error (SSW)
Differences from Random variation
group to group
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 14
Total Sum of Squares
DCOVA
SST = SSA + SSW
c nj
SST = ( Xij − X) 2
Where: j=1 i=1
SST = Total sum of squares
c = number of groups or levels
nj = number of values in group j
Xij = ith observation from group j
X = grand mean (mean of all data values)
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 15
Total Variation DCOVA
(continued)
2 2 2
SST = ( X 11 − X ) + ( X 12 − X ) + + ( X cn − X )
c
Response, X
Group 1 Group 2 Group 3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 16
Among-Group Variation
DCOVA
SST = SSA + SSW
c
SSA = n j ( X j − X)2
j=1
Where:
SSA = Sum of squares among groups
c = number of groups
nj = sample size from group j
Xj = sample mean from group j
X = grand mean (mean of all data values)
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 17
Among-Group Variation
(continued)
c
DCOVA
SSA = n j ( X j − X)2
j=1
Variation Due to SSA
Differences Among MSA =
Groups. c −1
Mean Square Among =
SSA/degrees of freedom.
i j
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 18
Among-Group Variation
DCOVA
(continued)
SSA = n1 (X1 − X) + n 2 (X 2 − X) + + n c (X c − X)
2 2 2
Response, X
X3
X2 X
X1
Group 1 Group 2 Group 3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 19
Within-Group Variation
DCOVA
SST = SSA + SSW
c nj
SSW = ( Xij − X j ) 2
j=1 i=1
Where:
SSW = Sum of squares within groups
c = number of groups
nj = sample size from group j
Xj = sample mean from group j
Xij = ith observation in group j
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 20
Within-Group Variation
(continued)
DCOVA
c nj
SSW = ( Xij − X j )2
j=1 i=1
SSW
Summing the variation
MSW =
within each group and then
adding over all groups. n−c
Mean Square Within =
SSW/degrees of freedom.
μj
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 21
Within-Group Variation
DCOVA
(continued)
SSW = (X11 − X1 ) + (X12 − X 2 ) + + (X cn c − X c )
2 2 2
Response, X
X3
X2
X1
Group 1 Group 2 Group 3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 22
Computing formulas for Variations
Total variation in one-way ANOVA Use this
σ 2
2 𝑋 𝑖
𝑆𝑆𝑇 = 𝑋𝑖 −
𝑛
Among-group variation in one-way ANOVA
𝑇𝑗2 σ 𝑋𝑖 2
𝑆𝑆𝐴 = −
𝑛𝑗 𝑛
where 𝑇𝑗 = sum of data from group 𝑗
Within-group variation in one-way ANOVA
𝑆𝑆𝑊 = 𝑆𝑆𝑇 − 𝑆𝑆𝐴
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 23
Obtaining the Mean Squares
DCOVA
The Mean Squares are obtained by dividing the various
sum of squares by their associated degrees of freedom.
SSA Mean Square Among
MSA = (d.f. = c-1).
c −1
SSW
MSW = Mean Square Within
n−c (d.f. = n-c).
SST
MST = Mean Square Total
n −1 (d.f. = n-1).
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 24
One-Way ANOVA Table
DCOVA
Source of Degrees of Sum Of Mean Square F
Variation Freedom Squares (Variance)
Among SSA FSTAT =
c-1 SSA MSA =
Groups c-1
MSA
Within SSW
n-c SSW MSW = MSW
Groups n-c
Total n–1 SST
c = number of groups
n = sum of the sample sizes from all groups
df = degrees of freedom
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 25
One-Way ANOVA
F Test Statistic DCOVA
𝐻0 : 𝜇1 = 𝜇2 = ⋯ = 𝜇𝑐
𝐻1 : Not all 𝜇𝑗 are equal (where 𝑗 = 1,2, … , 𝑐)
◼ Test statistic MSA
FSTAT =
MSW
MSA is mean squares among groups.
MSW is mean squares within groups.
◼ Degrees of freedom
◼ df1 = c – 1 (c = number of groups)
◼ df2 = n – c (n = sum of sample sizes from all populations)
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 26
Interpreting One-Way ANOVA
F Statistic DCOVA
◼ The F statistic is the ratio of the among
estimate of variance and the within estimate
of variance:
◼ The ratio must always be positive.
◼ df1 = c -1 will typically be small.
◼ df2 = n - c will typically be large.
Decision Rule:
◼ Reject H0 if FSTAT > Fα,
otherwise do not reject
H0. 0 Do not Reject H0
reject H0
Fα
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 27
One-Way ANOVA
DCOVA
F Test Example
◼ You want to see if three Club 1 Club 2 Club 3
different golf clubs yield 254 234 200
different distances traveled 263 218 222
by ball struck on an 241 235 197
automated driving machine. 237 227 206
◼ You randomly select five 251 216 204
measurements from trials on
an automated driving
machine for each club.
◼ At the 0.05 significance
level, is there a difference in
mean distance?
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 28
One-Way ANOVA Example:
Scatter Plot DCOVA
Distance
Club 1 Club 2 Club 3 270
254 234 200 260 •
263 218 222 ••
250 X1
241 235 197 240 •
237 227 206 • ••
251 216 204 230
220
• X2 •
X
••
210
x1 = 249.2 x 2 = 226.0 x 3 = 205.8
•• X3
200 ••
x = 227.0 190
1 2 3
Club
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 29
One-Way ANOVA Example
Computations DCOVA
Club 1 Club 2 Club 3 𝑇1 = 254 + 263 + ⋯ + 251 = 1246
254 234 200
263 218 222 𝑇2 = 234 + 218 + ⋯ + 216 = 1130
241 235 197
237 227 206 𝑇3 = 200 + 222 + ⋯ + 204 = 1029
251 216 204 𝑛1 = 5 𝑛2 = 5 𝑛3 = 5
15
𝑋𝑖2 = 2542 + 2632 + ⋯ + 2042 = 778771 𝑛 = 15
𝑖=1
15
𝑋𝑖 = 254 + 263 + ⋯ + 204 = 3405 𝑐=3
𝑖=1
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 30
One-Way ANOVA Example
Computations
15 15
𝑋𝑖2 = 778771; 𝑋𝑖 = 3405; 𝑛 = 15; 𝑐 = 3
𝑖=1 𝑖=1
𝑇1 = 1246; 𝑇2 = 1130; 𝑇3 = 1029; 𝑛1 = 𝑛2 = 𝑛3 = 5
34052
SST = 778771 − = 5836
15
12462 11302 10292 34052
SSA = + + − = 4716.4
5 5 5 15
SSW = 5836 − 4715.4 = 1118.6
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 31
One-Way ANOVA Example
Computations
𝑋𝑖2 = 778771; 𝑋𝑖 = 3405; 𝑛 = 15; 𝑐 = 3
𝑇1 = 1246; 𝑇2 = 1130; 𝑇3 = 1029; 𝑛1 = 𝑛2 = 𝑛3 = 5
𝑆𝑆𝐴 4716.4
MSA = = = 2358.2
𝑐−1 3−1
𝑆𝑆𝑊 1119.6
MSW = = = 93.3
𝑛 − 𝑐 15 − 3
𝑀𝑆𝐴 2358.2
FSTAT = = = 25.2755
𝑀𝑆𝑊 93.3
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 32
One-Way ANOVA Example
Solution DCOVA
H0: μ1 = μ2 = μ3 Test Statistic:
H1: μj not all equal 𝑀𝑆𝐴 2358.2
FSTAT = = = 25.2755
= 0.05 𝑀𝑆𝑊 93.3
df1= 2 df2 = 12
Decision rule:
Reject H0 when 𝐹𝑆𝑇𝐴𝑇 > 3.89
Critical Value:
Decision:
𝑭𝟎.𝟎𝟓,𝟐,𝟏𝟐 = 𝟑. 𝟖𝟗 Since 𝐹𝑆𝑇𝐴𝑇 > 3.89, we reject 𝐻0
= .05 Conclusion:
At 𝛼 = 0.05, there is evidence
0 Do not Reject H0 that at least one μj differs from
reject H0
F0.05,2,12 = 3.89 the rest.
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 33
Obtaining critical value
◼ 𝛼 = 0.05
◼ Degree of freedom in the numerator, 𝑑𝑓1 = 2
◼ Degree of freedom in the denominator, 𝑑𝑓2 = 12
◼ Refer to Table E.5 (pg. 493)
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 34
One-Way ANOVA
Excel Output DCOVA
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 35
You Must Make Three Assumptions About
Your Data To Use The ANOVA F Test
DCOVA
◼ Randomness and Independence
◼ Of the samples selected.
◼ Normality
◼ Of the c groups from which the samples are selected.
◼ Homogeneity of Variance:
◼ The variances of the c groups are equal.
◼ Can be tested with Levene’s Test.
Copyright © 2017, 2014, 2011 Pearson Education, Inc. Chapter 11 - 36