Analysis of variance gives us a view in statistical way to show whether the means of several groups are equal or not. It also generalizes the t – test for more than one group.
If we do two multiple sample t – test then it can increases the chances of having a type l error in the result. Therefore analysis of variance is always very useful to compare three or more than three means groups which is significant for statistical.
Two ways analysis of variance is just an extension of one way analysis of variance in which we test the effect of different categorical independent variable on one dependent variable. We use two ways analysis of variance when there is more than one independent variable and the observation is for every single independent variable. Two ways analysis of variance is also used to observe multiple independent variables. By using two ways analysis of variance we cannot only determine the contributed effect of each independent variable but we can also learn that if there is a important interaction between the independent variable.
There are some assumptions which one has to follow when using two ways analysis of variance. The assumptions are as follows:
1) We should normally distribute the errors of populations from which we obtained the sample.
2) If the sampling is done correctly then the observation must be independent for within and for between the groups.
3) We should make sure that the variances come to be equal among the population. The data can be nominal or it can be interval.
4) When an experiment gives us a quantitative outcome and two of its categorical explanatory variables defined in such a manner that each unit can be exposed to any combined level of an explanatory variable and the other level to the other explanatory level then the most commonly used analysis is two ways variance of analysis. Two ways analysis of variance consist of two possible mean models they are the additive model and the interaction model. In the first model which is additive model it is assumed that the effect on the outcome of particular level change for one explanatory level. It does not depend on the other level of explanatory variable. In the interaction model of two ways analysis of variance the change of one explanatory variable does effect on the other level of explanatory variable. In this model the one variable depend on the other.
Example:Let us assume that you want to calculate whether a particular brand of shower gel used and the temperature affects the amount of foam that is created. Suppose we buy two different brand of shower gels: “Super” and “Best”, and choose three different temperature levels of water: “cold”, “warm”, and “hot”. Now gather 6 people and assign each one the combination of “Super” and “Best” gel and “cold”,”warm”, and “hot” water. We are interested in testing Null Hypotheses.
H
_{0}D : The amount of foam created does not depend on the type of gel
H
_{0}T : The amount of foam created does not depend on temperature
One says the experiment has two factors (The Factor Gel, The Factor Temperature) at, a = 2 (Super and Best) and b = 3(cold, warm and hot) levels. Thus there are a * b = 3 × 2 = 6 different combinations of gel and temperature. With each combination you wash r = 4 times. ‘r’ is called the number of replicates which sums up to n = a * b * r = 24 washes in total.
The amounts Y$_{ijk}$ of foam created when washing small portion, k (k = 1, 2, 3, 4) with gel, i (i = 1, 2) at temperature j (j = 1, 2, 3) are recorded in Table 1.

Cold

Warm

Hot

Super

4, 5, 6, 5 
7, 8, 9, 12 
10, 12, 11, 9

Best 
6, 6, 4, 4 
13, 15, 12, 12

12, 13, 10, 13 
Solution:

Cold 
Warm

Hot

m_{D}

Super 
4, 5, 6, 5 
7, 8, 9, 12 
10, 12, 11, 9 
8 
Best 
6, 6, 4, 4

13, 15, 12, 12 
12, 13, 10, 13 
10 
m_{T} 
5 
11

11

9

• Calculating S S
_{within} and df
_{within}S S
_{within} = $\sum $(i = 1)
^{2} $\sum $(j = 1)
^{3} $\sum $(k = 1)
^{4} (Y
_{ijk} – Y
_{ij})
^{2}= (4 – 5)
^{2} + (5 – 5)
^{2} + (6 – 5)
^{2} + (5 – 5)
^{2} + (7 – 9)
^{2} + (9 – 9)
^{2} + (8 – 9)
^{2} + (12 – 2)
^{2} + ….. + (12 – 12)
^{2} + (13 – 12)
^{2} +(10 – 12)
^{2} + (13 – 12)
^{2}= 38
df
_{within} = (r – 1) a b = 3 X 2 X 3 = 18
M S
_{within} = S S
_{within} / df
_{within}n = 2.1111
• Calculating S S
_{gel} and df
_{gel}S S
_{gel} = r . b $\sum $(i = 1)
^{2} (Y
_{i} – Y
_{..})
^{2}= 4 X 3 X [(8 – 9)
^{2} + (10 – 9)
^{2}]
= 24
df
_{gel} = a – 1 = 1
M S
_{gel} = S S
_{gel}/ df
_{gel}= 24
• Calculating S S
_{temperature} and df
_{temperature}S S
_{temperature} = r . a $\sum $(j = 1)
^{3}3 (Y_j bar – Y_.. bar)
^{2}= 4 X 2 [(5 – 9)^2 + (11 – 9)^2 + (11 – 9)^2]
= 162
df
_{temperature} = b – 1 = 2
M S
_{temperature} = S S
_{temperature} / df
_{temperature}= 162 / 2 = 81
• Calculating S S_interaction and df_interaction
S S_interaction = r $\sum_{i=1}^{2}\sum_{j=1}^{3}(\bar{Y}_{ij}\bar{Y}_{i}\bar{Y}_{j}+\bar{Y}_{..})^{2}$
= 4 [(5 – 8 – 5 + 9)
^{2} + (9 – 8 – 11 + 9)
^{2} + (110 – 8 – 11 + 9)
^{2} + … +
(12 – 11 – 10 + 9)
^{2}]
= 12
df
_{interaction} = (a – 1) X (b – 1) = 2
$M S_interaction$ =
$\frac{S S_{interaction}}{ df_{interaction}}$ =
$\frac{12 }{ 2}$ = 6
• The F – test
M S
_{gel} / M S
_{within}$\sim $ F(df
_{gel} , df
_{within})
M S
_{interaction} / M S
_{within}$\sim $ F(df
_{interaction}, df
_{within})
M S
_{temperature} / M S
_{within} $\sim $ F(df
_{temperature}, df
_{within} )