BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
Lecture 6: Multi-sample Hypotheses - Analysis of Variance (ANOVA)
Introduction
The multisample null hypothesis is:
𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 = ⋯ ⋯ ⋯ = 𝜇𝑘
where k is the number of treatments.
The alternative hypothesis is:
𝐻0 : not all means equal
The multi-sample hypothesis is conducted using a method called Analysis of Variance, often
abbreviated ANOVA (or less commonly, ANOV or AOV).
Three assumptions have to be met in order to use ANOVA procedure:
The k samples should come from a normal population.
The k samples should have equal variances, i.e., 𝜎12 = 𝜎22 = ⋯ ⋯ ⋯ = 𝜎𝑘2 . This condition
is called homoscedasticity. If the variances are not equal, the condition is called
heteroscedasticity.
The observations should be independent.
Why analysis of variance and not multiple two-sample t-tests?
It is tempting to some to attempt the testing of multi-sample hypotheses by applying two-
sample t-tests to all possible pairs of samples.
Such a procedure is invalid.
The calculated tests statistic, t, and the critical values we find in the t table, are designed to
test whether two sample statistics, 𝑋̅1 and 𝑋̅2 , are likely to have come from the same
population (or from two populations with identical means).
Let’s assume we are testing the following multi-sample hypothesis: 𝐻0 : 𝜇1 = 𝜇2 = 𝜇3 and we
employ the two-sample test on the following three null hypotheses:
𝐻0 : 𝜇1 = 𝜇2
𝐻0 : 𝜇1 = 𝜇3
𝐻0 : 𝜇2 = 𝜇3
1
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
In performing the three possible two-sample t-tests indicated above, with = 0.05, the
probability of wrongly concluding that two of the means estimate different parameters is 14.3
%, i.e. 1 − (0.95)3.
Similarly, if is set at 0.05 and four means are tested, two at a time, by the two-sample t-
test, there are six pairwise H0’s and there is 18.5 % ( 1 − 0.954 ) chance of wrongly
concluding a difference of one or more of the means.
Mechanics of analysis of variance: Motivational example
Example 1. Sums of squares decomposition for univariate ANOVA
Analysis of variance is based upon the following decomposition of observations:
𝑂𝑏𝑠𝑒𝑟𝑣𝑎𝑡𝑖𝑜𝑛 = 𝑜𝑣𝑒𝑟𝑎𝑙 𝑚𝑒𝑎𝑛 + 𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 𝑒𝑓𝑓𝑒𝑐𝑡 + 𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠
𝑥𝑖𝑗 = 𝑥̅ + (𝑥̅𝑖 − 𝑥̅ ) + (𝑥𝑖𝑗 − 𝑥̅𝑖 )
Consider the following independent example. Eight pigs of equal weights are randomly assigned
to three diets: Diet A, Diet B and Diet C. After a month, weight gain is measured in kilograms.
Diet A Diet B Diet C
9 0 3
6 2 1
9 2
From the data above,
The overall mean weight gain of all pigs =4
Mean weight gain of pigs fed on diet A =8
Mean weight gain of pigs fed on diet B =1
Mean weight gain of pigs fed on diet C =2
We can decompose the data above as follows:
𝑂𝑏𝑠𝑒𝑟𝑣𝑎𝑡𝑖𝑜𝑛 = 𝑜𝑣𝑒𝑟𝑎𝑙 𝑚𝑒𝑎𝑛 + 𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 𝑒𝑓𝑓𝑒𝑐𝑡 + 𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠
𝑥𝑖𝑗 = 𝑥̅ + (𝑥̅𝑖 − 𝑥̅ ) + (𝑥𝑖𝑗 − 𝑥̅𝑖 )
2
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
The resulting arrays are shown below:
9 6 9 4 4 4 4 4 4 1 −2 1
(0 2 ) = (4 4 ) + (−3 −3 ) + (−1 1 )
3 1 2 4 4 4 −2 −2 −2 1 −1 0
Note: The decomposition is explained well in class.
The question of equality of means is answered by assessing whether the contribution of the
treatment array is large relative to the residuals.
If the treatment contribution is large, the null hypothesis should be rejected.
The size of an array is quantified by stringing the rows of the array out into a vector and
calculating its squared length. This quantity is called the sum of squares.
For the observations, we construct the vector 𝑦′ = [9, 6, 9, 0, 2, 3, 1, 2]. Its squared length is:
𝑆𝑆𝑜𝑏𝑠 = 92 + 62 + 92 + 02 + 22 + 32 + 12 + 22 = 216
Similarly,
𝑆𝑆𝑚𝑒𝑎𝑛 = 42 + 42 + 42 + 42 + 42 + 42 + 42 + 42 = 128
𝑆𝑆𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 = 42 + 42 + 42 + (−3)2 + (−3)2 + (−2)2 + (−2)2 + (−2)2 = 78
𝑆𝑆𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠 = 1 + (−2)2 + 12 + (−1)2 + 12 + 12 + (−1)2 + 02 = 10
The sum of squares satisfy the same decomposition as the observations.
𝑆𝑆𝑜𝑏𝑠 = 𝑆𝑆𝑚𝑒𝑎𝑛 + 𝑆𝑆𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 + 𝑆𝑆𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠
216 = 128 + 78 + 10
The breakup into sums of squares apportions variability in the combined samples into mean,
treatment, and residual (error) components.
An analysis of variance proceeds by comparing the relative sizes of 𝑆𝑆𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 and 𝑆𝑆𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠 .
If the null hypothesis is true, variances computed from 𝑆𝑆𝑡𝑟𝑒𝑎𝑡𝑚𝑒𝑛𝑡 and 𝑆𝑆𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙𝑠 should be
approximately equal.
We will demonstrate on how to construct the ANOVA table using the same data in Example
2.
3
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
Example 2. Fisher's approach to ANOVA
The approach present here will be the one to be followed throughout this course. It is based on
the computational formula of variances:
2
(∑ 𝑋𝑖 )
∑ 𝑋𝑖2 − 𝑆𝑢𝑚𝑠 𝑜𝑓 𝑠𝑞𝑢𝑎𝑟𝑒𝑠
𝑠2 = 𝑛
=
𝑛−1 𝑑𝑒𝑔𝑟𝑒𝑒𝑠 𝑜𝑓 𝑓𝑟𝑒𝑒𝑑𝑜𝑚
We will test if there are any differences in mean weights, in kilograms, of pigs after they were
fed three diets (the same experiment as in Example 1).
We start out by writing the hypotheses:
𝐻0 : There is no difference in mean weight gain among pigs fed three different diets, or
𝐻0 : 𝜇1 = 𝜇2 = 𝜇3
𝐻𝑎 : There is a difference in mean weight gain among pigs fed three different diets, or
𝐻0 : not all means equal
Diet A Diet B Diet C
9 0 3
6 2 1
9 2
𝑛𝑖 3 2 3 𝑘
𝑁 = ∑ 𝑛𝑖 = 8
𝑖=1
𝑛𝑖
∑ 𝑋𝑖𝑗
24 2 6
𝑗=1
Total number of all observations = 𝑁 = ∑𝑘𝑖=1 𝑛𝑖 = 3 + 2 + 3 =8
Grand total = ∑𝑖 ∑𝑗 𝑋𝑖𝑗 = 24 + 2 + 6 = 32
Computation of important quantities
A. Computing the correction factor (CF)
2
(∑𝑖 ∑𝑗 𝑋𝑖𝑗 )
CF = 𝑁
(32)2
= 8
= 128
4
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
Note: This is the same as the mean sums of squares when decomposed the observation array into
several arrays.
B. Computing sums of squares (SS)
a) Total sums of squares (TSS):
This is the variability present among all N observations; that is,
𝑛 2
TSS = ∑𝑘𝑖=1 ∑𝑗=1
𝑖
(𝑋𝑖𝑗 − 𝑋̅) . This is the definitional formula.
Computationally,
2
TSS = ∑𝑖 ∑𝑗 𝑋𝑖𝑗 − 𝐶𝐹
= (92 + 62 + ⋯ ⋯ + 22 ) − 128
= 216 − 128
= 88
Note: Identify this quantity when we decomposed the observation array into several arrays. The
total sums of squares is 88, is the difference between the sums of squares for observations (216)
and the sums of squares for the mean (128)
b) Treatment sums of squares (SST)
This is the variability among the k levels of the factor, which will be called treatments from now
onwards. The definitional formula for SST is:
SST = ∑𝑘𝑖=1 𝑛𝑖 (𝑋̅𝑖 − 𝑋̅)2
Computationally,
2
(∑𝑗 𝑋𝑖𝑗 )
SST = ∑𝑖 − 𝐶𝐹
𝑛𝑖
242 22 62
=( + + ) − 128
3 2 3
= 206 − 128
= 78
Note: Identify this quantity when we decomposed the observation array into several arrays.
5
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
c) Error sums of squares (SSE)
In ANOVA, we assume that the variances of the levels of a factor are equal and we estimate the
population variance assumed to all k groups by a variance obtained using the pooled sum of
squares and the pooled degrees of freedom for all the levels (SSE), whose definitional formula is:
𝑛𝑖 2
SSE = ∑𝑘𝑖=1 [∑𝑗=1(𝑋𝑖𝑗 − 𝑋̅𝑖 ) ]
Computationally, SSE is the difference between TSS and SST.
Error sums of squares (SSE) = TSS – SST
= 88 – 78
= 10
C. Computing degrees of freedom (df)
Total degrees of freedom = N – 1= 8 – 1` =7
Treatment degrees of freedom (Trt df) =k–1=3–1 =2
Error degrees of freedom (E df) = N- k= 8 – 3 =5
D. Computing mean squares (MS)
In general,
𝑠𝑠
MS= 𝑑𝑓
Note: Mean squares is Fisher's terminology for variances.
Therefore,
𝑆𝑆𝑇 78
Mean squares for treatment (MST) = 𝑡𝑟𝑡 𝑑𝑓 = = 39
2
𝑆𝑆𝐸 10
Mean squares for error (MSE) = 𝐸 𝑑𝑓 = =5
2
Note:
Statistical theory informs us that if the null hypothesis is a true statement about the
populations, then MST and MSE will each be an estimate of the variance common to all k
populations.
But if k population means are not equal, then the group MS in the population will be greater
than the population’s error MS.
6
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
Therefore, the test for the equality of means is a one-tailed variance ratio test, where group
MS is always placed in the numerator so as to ask whether it is significantly larger than MSE.
E. Computing F-value
We calculate the F value using the following formula
𝑀𝑆𝑇
Fcalculated = 𝑀𝑆𝐸
39
= 2
= 18.5
We compare this to the F-value that we get from an F table.
Ftabulated = 𝐹0.05(1),2,5
= 5.79
The tabulated F value has 2 numerator degrees of freedom and 5 numerator degrees of freedom.
Using an = 0.05, it can be written as follows: 𝐹0.05(1),2,5 . The 1 in brackets means that the F
test is a one-sided test.
F. Constructing the ANOVA table
From the information above, we can construct the following ANOVA table:
Source of Sums of Degree of Mean Calculated Tabulated
variation Squares freedom Squares F F
Treatment 78 2 39 18.5 5.79
Error 10 5 2
Total 88 7
G. Decision
Since the calculated F is greater than the tabulated F, we reject the null hypothesis.
H. Conclusion
We conclude that we have sufficient evidence that there are no significant differences in mean
weights among pigs fed the three diets at 5 % level of significance.
7
Lecture 6 [email protected]
BSC 311: Design and Analysis of Experiments First Semester 2023/24 Academic Year
ANOVA model
The basic elements of the ANOVA model for a single-factor study are quite simple. The
ANOVA model assumes that:
Each probability distribution of the response variable is normal.
Each probability distribution has the same variance
The responses for each factor level are random selections from the corresponding
probability distribution and are independent of the responses for any factor level.
The model for a single-factor ANOVA can be stated as follows:
𝑌𝑖𝑗 = 𝜇 + 𝜏𝑖 + 𝜀𝑖𝑗
Where
𝑌𝑖𝑗 denotes the value of the response variable in the jth trial for the ith factor level.
𝜇 is the overall mean
𝜏𝑖 is the effect of the ith factor level or treatment
𝜀𝑖𝑗 are random and independent errors.
Notes on the statistical model from the decomposition of the observation matrix
The overall mean does not vary between treatments or replicates (columns or rwos). It
doesn't get a subscript letter.
The treatment effects vary among the three treatments. This is the reason we carried out the
experiment in the first place. Therefore, the subscript in 𝜏𝑖 shows this variation. Remember
that ∑ 𝜏𝑖 = 0.
The residual or random error varies among the treatments and replicates. That is why 𝜀𝑖𝑗 has
two subcripts, i.e., i standing for treatments and j standing for replicates.
Remember that if the ANOVA models fit well, the random errors are supposed to be
normally distributes with a mean of zero and constant variance. In short, this is written as
𝑁(0, 𝜎 2 ). Again, ∑ 𝜀𝑖𝑗 = 0.
8
Lecture 6 [email protected]