Professional Documents
Culture Documents
Two Way
Two Way
VARIANCE
Structure
7.1 Introduction
Objectives
7.2 Two-way ANOVA Model with One Observation per Cell
7.3 Assumptions of Two-way ANOVA
7.4 Estimation of Parameters in Two-way Classified Data
7.5 Test of Hypothesis in Two-way ANOVA
7.6 Degrees of Freedom of Sum of Squares
7.7 Expectations of Various Sum of Squares
Expectation of Sum of Squares due to Factor A
Expectation of Sum of Squares due to Factor B
Expectation of Sum of Squares due to Error
7.8 Summary
7.9 Solutions /Answers
7.1 INTRODUCTION
In Unit 6 of this block, we have discussed the one-way analysis of variance. In
one-way analysis of variance, we have considered one independent variable at
different levels which affects the response variable. Analysis of variance is a
technique which split up the total variation of data which may be attributed to
various “sources” or “causes” of variation. There may be variation between
variables and also within different levels of variables. In this way, analysis of
variance is used to test the homogeneity of several population means by
comparing the variances between the sample and within the sample. In this
unit, we will discuss the two-way analysis of variance technique. In two-way
analysis of variance technique, we will consider two variables at different
levels which affect the response variables.
In Section 7.2 the two-way ANOVA model is explained whereas the basic
assumptions in two-way ANOVA are described in Section 7.3. The estimates
of each level mean of each factor are found in Section 7.4. Test of hypothesis
in two-way ANOVA is explained in Section 7.5 and the degrees of freedom of
various sum of squares in two-way ANOVA are described in Section 7.6.
Expectations of various sum of squares are derived in Section 7.7.
Objectives
After reading this unit, you would be able to
explain the two-way ANOVA Model;
describe the basic assumptions in two-way ANOVA;
find the estimate of each level mean of each factor;
explain the degrees of freedom of various sum of squares in two-way 41
ANOVA;
Analysis of Variance
derive the expectations of various sum of squares;
construct the ANOVA Table for two-way classification and determine the
critical differences; and
perform the two-way ANOVA test.
In the previous unit, we have considered the case where you had one
categorized predictor/independent variable/explanatory at different levels. In
this unit, consider a case with two categorical predictors. In general, some
times you have more than one categorical predictor variables at a different
levels and a continuous response variable then it is called two-way
classification.
Mathematical Model
Here, the mathematical model may be written as
yij = µij + eij
where, eij are independently normally distributed with common mean zero and
variance σe2. Corresponding to above table of observations following table is a
table of expected values of observations:
Table of Expectations of Observations of yij
A/B B1 B2 … Bj … Bq Mean Difference
A1 µ11 µ12 … µ 1j … µ1q µ1. 1. 1
A2 µ21 µ22 … µ2j … µ2q µ2. 2. 2
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Ai µi1 µi2 … µij … µiq µi. i i
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
Ap µp1 µp2 … µpj … µpq µp. p. p
Mean µ.1 µ.2 … µ.j … µ.q µ..
Difference µ.1-µ µ.2-µ … µ.j-µ … µ.q-µ
= β1 = β2 = βj = βq
43
Analysis of Variance
Now µij can be written as
µij = µ + (µi.-µ) + (µ.j - µ) + (µij- µi.- µ.j + µ)
= µ + αi + βj + (αβ)ij
or E (yij ) = µij = μ + αi+ βj + (αβ)ij
or yij = μ + αi + βj + (αβ)ij + eij
where µ is a constant general mean effect, present in all the observations,
αi = µi. - µ is an effect due to the ith level of the factor A, which is common to
all the observations belonging to this level of A , βj = µ.j - µ is an effect due to
jth level of the factor B, which is common to all the observations belonging of
this levels of B and (αβ)ij = µij - µi.+ µ.j + µ is called the interaction between
the ith level of A and jth level of B. It is an effect peculiar to the combination
(Ai Bj ). It is not present in the ith level of A or in the jth level of B if not taken
together i.e.if the joint effect of Ai and Bj is different from the sum of the
effects due to Ai and Bj taken individually, it means there is interaction and it
is measured by (αβ)ij.
In the case of two-way classified data with one observation per cell, the
interaction (αβ) cannot be estimated and, therefore, there is no interaction i.e.
(αβ)ij for all i and j. So, the model becomes
yij = µ + αi + βj + eij … (1)
y
i1 j1
ij i j 0
p q p q
or y ij pq q i p j 0
i 1 j1 i 1 j1
y ij pq q i p j 0
i 1 j1 i 1 j 1
p q
y
i 1 j1
ij pq
p q
y
i 1 j1
ij
or y..
pq
Similarly, differentiating E with respect to 1 , 2 , ..., p , we get
for i=1, i.e. for estimating 1
q
E ( y1 j 1 j )2
j1
q
E
2 y1 j µ α1 β j
α1 j1
y
j1
1j 1 j 0
q q
y1 j q q 1 j 0
j1 j1
45
Analysis of Variance q q
or y1 j q µ α1
j1
because β
j1
j 0
q
y 1j
or, 1 j 1
= y1. y..
q
or in general ˆ i y i. y.. for all i =1, 2, ..., p.
Similarly for obtaining the least square estimate for j we have to differentiate
E w.r.t. j and equating to zero, we have
p
E
2 yij µ α i β j 0
β j i 1
p p p p
or yij i j 0
i 1 i 1 i 1 i 1
p p
or y
i 1
ij pµ pβj 0 because α i 0
i 1
p
1
or j yij
p i 1
j y. j y.. for all j =1, 2, . . . , q
p q p q
It is clear that i 0 ,
i 1
j 0 and
j 1
(αβ)
i 1 j1
ij 0
y..
pq
ˆ i yi. y.. for all i =1, 2 ,…, p.
j ( y. j y.. )
for all j =1, 2, … , q.
In this model each observation is the sum of four components and analysis of
p q
2
46 variance partitions y
i 1 j1
ij also in four components as follows:
yij y.. ( yi. y.. ) ( y. j y.. ) ( yij yi. y. j y.. ) Two-Way Analysis of
Variance
y
i 1 j1
ij y.. y i. y.. y. j y..
2
i1 j1
2
i1 j1
2
p q p q
y ij y i. y. j y.. 2 y i. y .. y. j y..
2
i 1 j1 i 1 j1
p q
2 yi. y.. yij yi. y. j y..
i 1 j1
p q
2 y. j y.. y ij y i. y . j y..
i 1 j1
Therefore,
p q p q
y
i 1 j1
ij y.. q y i . y .. p y. j y ..
2
i 1
2
j1
2
p q
y ij y i. y . j y..
2
i 1 j1
Other terms are zero because, sum of the deviation of observations from their
mean is always zero.
So, Total Sum of Squares = Sum of Squares due to Factor A (SSA)
+ Sum of Squares due to Factor B (SSB)
+ Sum of Squares due to Error (SSE)
or in short TSS = SSA + SSB + SSE
The corresponding partition on the total degrees of freedom is as follows:
df of TSS = df of SSA + df of SSB + df of SSE
pq-1 = (p-1) + (q-1) + (p-1)(q-1)
Dividing the sum of squares by their respective degrees of freedom (df), we
get corresponding mean sum of squares.
In two-way classified data, we can test two hypotheses, one for levels of
factor A that is equality of different levels of factor A
H0A: 1 = 2 = … = p = 0
H1A: 1 ≠ 2 ≠ … ≠ p ≠ 0
and for equality of different levels of factor B
H0B: β1 = β2 = … = βq = 0
H1B: β1 ≠ β 2 ≠ … ≠ β q ≠ 0
To derive the appropriate tests for these hypotheses we have obtained the
expected values of various sum of squares as explained in one-way classified
data in Section 7.7. 47
Analysis of Variance
So,
p
EMSSA e2 q i2 / p 1
i 1
q
EMSSB 2e p 2j / q 1
j1
E (MSSE) = σe2
If H0A: α1 = α 2 = . . . = α p = 0 is true, then E (MSSA) = E (MSSE) and hence
F = MSSA / MSSE will give the test to test H0A.
So, a test for the hypothesis of equality of the effect of the different levels of
factor A is provided by this F, which follows the Snedecor F- distribution with
[(p-1), (p-1)(q-1)] df.
Thus, the null hypothesis will be rejected at α level of significance if and only
if F = MSSA/MSSE > F tabulated [(p-1), (p-1) (q-1)] df at α level of
significance.
Similarly if, H0B: β1 =β2 = … = βq = 0 for the equality of the effects of the
different levels of B is true then E(MSSB) = E(MSSE) and F = MSSB/MSSE
will give the test to test H0B. H0B is rejected at the α level of significance if and
only if F = MSSB/MSSE > F tabulated [(q-1), (p-1) (q-1)]df at α level of
significance. These calculations are shown in the following table.
ANOVA Table for Two-way Classified Data with One Observation
per Cell
Source of DF SS MSS F
Variation
p-1 p
Between SSA= q y i. y.. 2 MSSA F(p-1), (p-1)(q-1) =
the Levels i 1 MSSA/MSSE
of A = SSA/(p-1)
q-1 q
Between SSB= p y. j y.. 2 MSSB F(q-1), (p-1)(q-1) =
the Levels j1 MSSB/MSSE
of B =SSA/(q-1)
i1 j1
If both the null hypotheses are rejected then the means of the different levels
of factors A and B can be tested by the method of multiple comparisons given
by Tukkey.
7.5.1 General Computation Procedure
For analysing the two-way classified data, with one observation per cell, one
has to follow the following procedure:
48
p q Two-Way Analysis of
1. Calculate G = Grand Total = Total of all observations = yij Variance
i 1 j1
49
Analysis of Variance q
For obtaining the valid test statistic, the expected value of various sum of
squares should be obtained:
7.7.1 Expectation of Sum of Squares due to Factor A
p
SSA q y i . y ..
2
We have
i 1
p 2
E (SSA ) E q y i . y..
i 1
p 2
E SSA q E y i. y..
i1 … (2)
We know that y ij i j e ij
1 q 1 q
So yi . y ij i j eij
q j 1 q j 1
q q
1
or yi .
q
q q i j e ij
j 1 j1
= µ αi ei.
y.. e..
p
E (SSA) = q E µ α i e i . µ e .. 2
50 i 1
p Two-Way Analysis of
= q E α i ei. e.. 2 Variance
i 1
p p p
= q E i2 ei. e.. 2 2 i ei. e..
i 1 i 1 i 1
p p p
= q i2 E ei. e.. 2 2 i E ei . e..
i 1 i 1 i 1
Since eij ~ iidN (0, 2e ), so E e ij 0 Var e ij e2
σ2 σ2
ei. ~ iidN 0, e ; E ei. 0 Var ei. e
q q
σ2 σ2
and e.. ~ iidN 0, e ; E e.. 0 Var e.. e
pq pq
p p
2
So E(SSA) q α 2i q Eei. e.. 0
i1 i 1
p
p p
q i2 qE ei2. p e..2 2 e.. e i.
i 1 i 1 i 1
p
p 1 p
q α i2 qE ei2. p e..2 because e.. ei .
i 1 i 1 p i 1
p
p
q α i2 q E ei2. pE e..2
i1 i 1
p
2 2
q i2 q p e p e
i 1 q pq
p
E (SSA ) q i2 p 1 2e
i 1
p
SSA q 2
E i e2
p 1 ( p 1) i 1
j1
q 2
51
E (SSB ) E p y . j y..
j1
Analysis of Variance
q 2
p E y . j y..
j1 … (3)
We know that y ij i j e ij
1 p 1 p
So y. j
p i 1
y ij
p i 1
i j e ij
p p
1
or y. j p i p j e ij
p i 1 i 1
= j e. j
y.. e..
Substituting the values of y. j and y.. in equation (3), we have
q
E (SSB) = p E µ β j e. j µ e.. 2
j1
q
= p E β j e. j e.. 2
j1
q q q
= p E β 2j e. j e.. 2 2 β j e. j e..
j1 j1 j1
q q q
= p β 2j E e. j e.. 2 2E β j e. j e..
j1 j1 j1
Since, eij ~ iid N( 0, 2e ), so E e ij 0 Var e ij e2
2 2
e. j ~ iid N 0, e E e. j 0 Var e. j e
p p
2 2
and e.. ~ iid N 0, e E e.. 0 Var e.. e
pq pq
q q q
p β 2j pE e.2j q e..2 2 e.. e. j
j1 j1 j1
q q 1 q
p β 2j pE e.2j q e..2 because e.. e. j
j1 j1 q j1
q q
52
p β 2j p E e.2j qE e..2
j1 j1
q
2 2 Two-Way Analysis of
p 2j p q e q e Variance
j1 p pq
q
E(SSB) p 2j q 1 e2
j1
q
SSB p 2
E j e2
q 1 (q 1) j1
p q p q p q
2 ei. e. j 2 ei. e.. 2 e. je..
i 1 j1 i 1 j1 i 1 j1
p q p q p
E e 2ij q e i2. p e .2j pq e..2 2q e i2.
i 1 j1 i 1 j1 i 1
q
2p e .2j 2pq e..2 2pq e..2 2pq e..2 2 pq e..2
j1
p q p q
E e 2ij q e i2. p e.2j pq e..2
i 1 j1 i1 j1
p q p q
ESSE E(e2ij ) q E(e i2. ) p E( e.2j ) pqE( e..2 )
i1 j1 i1 j1
2e 2 2
so E(SSE) = pq e2 qp. pq e pq. e
q p pq
= (pq-p-q+1) 2e
No. of observations = N = 9
2 MSSE 23
and the value t(p-1) (q-1) 2.1776 3.93
3 3
Since, all ( y i. - y j. ) > 3.93. So, we conclude that there is a significance
difference among the yield of shrimp due to different levels of temperature.
Blocks Treatments/Diets
A B C D
I 12 8 6 5
II 15 12 9 6
III 14 10 8 5
7.8 SUMMARY
In this unit, we have discussed:
1. The two-way analysis of variance model;
2. The basic assumptions in two-way analysis of variance;
3. Test of hypothesis using two-way analysis of variance; and
4. Expectations of various sum of squares.
56
Two-Way Analysis of
7.9 SOLUTIONS /ANSWERS Variance
Against, H1A : αi α 2 α 3
H 0 B : i 2 3 4
H1B : β i β 2 β 3 β 4
355.5096
Total Sum of Squares (TSS) = RSS – CF
= 355.5096-283.0465= 72.4631
Sum of Squares due to Data of Planting (SSD)
D12 D22 D32 D24
CF
3 3 3 3
=
25.692 12.062 14.182 6.352 283.0465
3 3 3 3
= 65.8917
Sum of Squares due to Method of Planting (SSM)
M12 M 22 M32
CF
4 4 4
=
17.39 22.31 15.58
2
2
2
283.0465
4 4 4
= 286.3412-283.0465 = 3.2947
Sum of Squares due to Error (SSE) = TSS-SSD-SSM
= 72.4631-3.2947-65.8917 57
= 3.2767
Analysis of Variance
ANOVA Table
Source of SS DF MSS F
Variation
Between 3.2947 2 3.2947 1.6473
Method 1.6473 F1 3.02
2 0.5461
Between 65.8917 3 65.8917 21.9639
Data 21.9639 F2 40.22
3 0.5461
2MSSE
CD = t error df 2.447 0.3641 = 1.48
3
The mean field differences of the four data of planting are given as:
D1 D2 8.56 4.02 4.54
I 144 64 36 25 269
II 225 144 81 36 486
III 196 100 64 25 385
Totals 565 308 181 86 1140
Grand Total = G = y ij = 110
G 2 110
2
Source of SS DF MSS F
Variation
Between 113.6667 3 113 .6667 37.8889
Treatments/ F1
3 0.4722
Diets 37.8889 80.2391
Between 15.1667 2 15.1667 7.58335
Blocks F2
2 0.4722
7.58335 160 .596
Due to Errors 2.8333 6 2.8333
6
0.4722
Total 131.6667 11
60