Professional Documents
Culture Documents
Two-Way Anova
Two-Way Anova
Two-Way Anova
Here we study the effect of two factors simultaneously, say factor A and factor B. The studies
can be based on experimental on observational data.
Notations
For now, we assume equal sample size in each treatment combination. This is called a balanced
design.
Example
The effect of sales based on three selling prices (Kshs 59, Ksh 60, Ksh 64) and two types of
promotional campaign (radio advertisement or newspaper advertisement)
Here, Y response is the number of items sold. Factor A is price which has 3 levels i.e., a 3 ,
factor B is types of promotional campaign which has 2 levels , i.e., b 2 . For this case, there are
6 treatments , i.e., ab 6
We assume that the response variable of the observations are independent and normally
distributed with a mean that may depend on the levels of the factors A and B, the variance is
constant.
Model formulation
We express the analysis of variance model in terms of the cells (treatment) mean ij . The model
is of the form
Where ij is the theoretical mean or the expected value of all observations in the cell i, j ,
ij ~ N 0, 2 iid and Yijk ~ N ij , 2 they are independent.
There are ab 1 parameters of the model. In this case ij , i 1,2, , a , j 1,2,, b
Factor B
1 2 3 b Mean
Factor A 11 12 13 1b 1
1 21 21 23 2b 2
2 31 32 33 3b 3
3
a1 a 2 a3 ab a
a
1 2 3 b
Parameter estimates
Y ijk
Y ij k
, that is ̂ij Y ij which is the treatment mean.
nk
Parameter definitions
∑ 𝜇𝑖•
ij i ∑ 𝜇•• = 𝑖
𝑎
i j
or i
or 𝜇•• = 𝑖
𝑏
ab a
Treatment mean
The mean response for a given treatment is denoted as ij where i refers to the level of factor A
i 1,2,, a and j refers to the level of factor B j 1,2,, b
ij
j i 1
a
j 1
ij
i
b
Example
Suppose we want to determine whether the brand of laundry detergent used and the
temperature affects the amount of dirt removed from the laundry work. To this end, you buy
two different brand of detergent (“super” and “best”) and choose three different temperature
levels (“cold”, “warm” and “hot”). Then you divide your laundry randomly into 6 k piles of
equal size and assign k piles into the combinations of (“super” and “best”) and (“cold”, “warm”
and “hot”). The amount of 𝑦𝑖𝑗𝑘 dirt removed when washing sub-piles k k 1,2,3,4 with
detergent i i 1,2 at temperature j j 1,2,3 are recorded in the table below.
Factor B
Cold Warm Hot
Factor A Super 4,5,6,5 7,9,8,12 10,12,11,9
Best 6,6,4,4 13,15,12,12 12,13,10,13
Solution
Treatment means
Y ijk
̂ij Y ij k
nk
Factor B (Temperature)
Cold Warm Hot Mean
Factor A Super 11 5 12 9 𝜇13 = 10 𝜇1• = 8.0
(Detergent) Best 21 5 22 13 23 12 2 10
Mean 1 5 𝜇•2 = 11 𝜇•3 = 11.0 𝜇•• = 9.0
a
ij j 1
ij
Column - j i 1
row - i
a b
Overall/grand mean
ij i i
i j
i
i
ab a a
The combination of “best” and “warm” has the maximum mean treatment.
Note:
i)
E Yijk ij
ii) Anova model (*) above could also be expressed as Y XB
Illustration
For two factor study with each factor having 2 levels i.e., a b 2 and two replicates, that is,
number of observations in each. Then Y , X, and can be defined as
Y111 1 0 0 0 111
Y 1
112 0 0 0 112
Y121 0 1 0 0 11 121
Y122 0 1 0 0 12 122
Y , X , and
Y211 0 0 1 0 21 211
Y212 0 0 1 0 22 212
Y 0 0 0 1
221 221
Y222 0 0 0 1 222
1 0 0 0 11
1 0 0 0
11
0 1 0 0 11 12
0 1 0 0 12 12
E Y X
0 0 1 0 21 21
0 0 1 0 22 21
0 0 0 1
22
0 0 0 1 22
FACTOR EFFECTS MODEL
The factor effects model is obtained by replacing treatment means ij with identical expression
in terms of factor levels. For two way Anova model, we have ij i j ij .
Replacing ij in model (*), we get
In this case ijk ~ N 0, which is a factor effects model for a two factor studies. Note that
2
E Yijk i j ij
This implies ij i j ij , that is, E Yijk ij
Where;
j j
a
2. Mean for the i th level of factor A
ij
i i
b
3. Mean effect of factor A of i th level
i i i i
th
4. Main effect of factor B on the j level
j j
5. ij is the difference between ij and i j , that is
ij i j ij
ij i j
ij i j
ij ij i j
When ij i j we say that factors are interacting. The interaction of the i th level of
factor A and j level of factor B is denoted by ij and is defined as above.
th
Remarks:
i) A model without the interaction term, that is, ij i j is called an additive
model.
ii) As in one way Anova model, we now have too many parameters hence we need
several constraints. The constraints are:
i 0
i
j 0
j
Parameter Estimate
Grand mean Y ijk
̂ Y i j k
abni
i i ˆ i ˆ i ˆ Y i Y
j j ˆ j ˆ j ˆ Y j Y
Example
Suppose we want to determine whether the brand of laundry detergent used and the
temperature affects the amount of dirt removed from the laundry work. To this end, you buy
two different brand of detergent (“super” and “best”) and choose three different temperature
levels (“cold”, “warm” and “hot”). Then you divide your laundry randomly into 6 k piles of
equal size and assign k piles into the combinations of (“super” and “best”) and (“cold”, “warm”
and “hot”). The amount of Yijk dirt removed when washing sub-piles k k 1,2,3,4 with
detergent i i 1,2 at temperature j j 1,2,3 are recorded in the table below.
Factor B
Cold Warm Hot
Factor A Super 4,5,6,5 7,9,8,12 10,12,11,9
Best 6,6,4,4 13,15,12,12 12,13,10,13
Compute:
i) Overall mean
ii) Main effect of factor A
iii) Main effect of factor B
iv) Interaction effects
Solution
∑ ∑ ∑ 𝑌𝑖𝑗𝑘
𝑘
𝑗 218
The overall mean is given by 𝜇̂ •• = 𝑌̅•• = 𝑖
𝑎𝑏𝑛𝑖
= 2×3×4 = 9.083
ˆ i ˆ i ˆ Y i Y
𝛼̂1 = 8.0 − 9.0 = −1.0
𝛼̂2 = 10 − 9.0 = 1.0
This indicates that the “best” laundry detergent increase the effectiveness of dirt removed by an
average of 1 . “super” laundry detergent decrease the effectiveness of dirt removed by an
average of 1 .
ˆ j ˆ j ˆ Y j Y
ˆ1 5 9 4
ˆ2 11 9 2
ˆ3 11 9 2
Warm and hot water increases the effectiveness of dirt removed by an average of 2 while cold
water decrease the effectiveness of dirt removed by average of 4 .
Note:
i
i 0 and
j
j 0
Interaction effects
ˆij i j
ˆ 21
1 , ˆ 22
1, ˆ 23 0
Note:
j
ij 0 and
i
ij 0,
Partitioning of total sum of squares
i j k
i j
i j k
We shall decompose the estimated treatment mean deviation y ij y . In terms of components
reflecting the factor A main effect, the factor B main effect and the interaction of factors A and B.
a
SSA nb y i y
2
i 1
b
SSB na y j y
2
j 1
SSAB n y ij y i y j y
2
i j
For two factor studies with n cases for each treatment, there are a total of nT nab cases,
r ab treatments, hence SST has nab 1 , SSTr has ab 1 and SSE has nab ab abn 1 .
This question needs to be answered first because if we conclude that there is significant
interaction, then both effects are important and hence each effect cannot be discussed
individually.
If we conclude that there is no significant interaction between the factors being studied, then we
can test the effects individually.
The three questions of interest in a two-way Anova can be formulated in terms of the following
parameter values.
Mean squares
The mean squares are the sum of squares divided by their degrees of freedom.
i) Interaction
MSAB
FAB ~ Fa1b1,ab n1 reject H 0 if FAB F ,a1b1,abn1 , otherwise do not
MSE
reject H 0 .
ii) Main effects of factor A
MSA
FA ~ Fa 1,ab n1 and reject H 0 if FA F ,a1,abn1
MSE
iii) Main effects of factor B
MSB
FB ~ Fb1,ab n1 and reject H 0 if FB F ,b1,abn1
MSE
Anova table for two-way factor study with fixed effects model
Example
Suppose we want to determine whether the brand of laundry detergent used and the
temperature affects the amount of dirt removed from the laundry work. To this end, you buy
two different brand of detergent (“super” and “best”) and choose three different temperature
levels (“cold”, “warm” and “hot”). Then you divide your laundry randomly into 6 k piles of
equal size and assign k piles into the combinations of (“super” and “best”) and (“cold”, “warm”
and “hot”). The amount of Yijk dirt removed when washing sub-piles k k 1,2,3,4 with
detergent i i 1,2 at temperature j j 1,2,3 are recorded in the table below.
Factor B
Cold Warm Hot
Factor A Super 4,5,6,5 7,9,8,12 10,12,11,9
Best 6,6,4,4 13,15,12,12 12,13,10,13
Test if the amount of dirt removed does depend on the type of detergent and the temperature.
Use 5% .
Solution
H 0 : ij 0
H1 : ij 0
y
2
Computing the interaction effect SSAB n ij y i y j y
i j
2 3
4 y ij y i y j y
2
i 1 j 1
4 5 8 5 9 9 8 11 9 5 10 5 9
2 2 2
12
The degrees of freedom is equal to a 1b 1 2
12
MSAB 6
2
2 3 4
SSE yijk y ij 4 5 5 5 6 5 38
2 2 2 2
i 1 j 1 k 1
38
MSE 2.111
18
6
FAB 2.844
2.111
F0.05, 2,18 3.555
Since 2.844 3.555 , we do not reject H 0 at 5% . This means that the interaction effect is
insignificant. Now we test for individual effects, that is, factor A effects and factor B effects.
H 0 : i 0
H1 : i 0
a
SSA nb y i y
2
i 1
438 9 10 9 24
2 2
Degrees of freedom a 1 1
24 24
MSA 24 , FA 11.374
1 2.111
F0.05,1,18 4.4
Since 11.374 4.4 , we reject H 0 at 5% . Therefore, amount of dirt removed depend on the
type of detergent used.
H0 : j 0
H1 : j 0
b
SSB na y j y
2
j 1
425 9 11 9 11 9 192
2 2 2
Degrees of freedom b 1 2
SSB 192
MSB 96
b 1 2
MSB 96
FB 45.48
MSE 2.111
F0.05, 2,18 3.555