

Analysis of Variance  Two Way
Practice Problems (Answers)
Homework
In addition to being able to analyze an experiment with one Independent Variable (IV), the ANOVA can be used for factorial designs (or designs which employ more than one IV). Note that, in this context, an IV is often referred to as a factor. The factorial design is very popular in the social sciences. It has a few advantages over single variable designs. The most important of these is that it can provide some unique and relevant information about how variables interact or combine in the effect they have on the DV.
Let's look at these design issues in more detail with a concrete example and then consider the unique information that this design provides.
Our example involves the effects of maternal consumption of ethanol on the behavior of the offspring of rats. The human literature had shown that children diagnosed with Fetal Alcohol Syndrome (FAS) were more active and impulsive than children not receiving this diagnosis. They also seemed to have a more difficult time controlling themselves (i.e., self restraint). These problems typically become less severe as the child ages.
The human literature is difficult to interpret however, because questions remain as to the cause and effect relationships involved. Were the behavioral abnormalities observed in the children with FAS due to the fact that their mothers consumed alcohol while they were pregnant? Or, were the abnormalities observed due to nutritional factors (since the diet of an alcoholic is typically not wholesome & well balanced)? Another possible causal factor of the abnormalities observed is spousal abuse.
Ethically, we cannot conduct the experiments necessary to determine the causal relations involved in humans. Thus, the experiment that will serve as our example employed rats as subjects (based on Riley, Lockrey & Shapiro, 1979). Earlier literature had demonstrated that rats can be used as an animal model of FAS. Offspring of rodents given alcohol when pregnant show similar morphological and behavioral changes to that observed in humans.
So, we will have two IVs or factors and each will have two levels (or possible values). The table below illustrates the design. Note that EDC refers to Ethanol Derived Calories.
Age (factor B) Adolescent Adult Maternal
Diet
(factor A)Chocolate
Milk
(0% EDC)n=5 n=5 White
Russian
(35% EDC)n=5 n=5
This is an example of a 2x2 factorial design with 4 groups (or cells), each of which has 5 subjects. This is the simplest possible factorial design. The DV used was a Passive Avoidance (PA) task. Rats are nocturnal, burrowing creatures and thus, they prefer a dark area to one that is brightly lit. The PA task uses this preference to test their learning ability. The apparatus has two compartments separated by a door that can be lifted out. One of the compartments has a light bulb which is controlled by the experimenter. Furthermore, the floor can be electrified. In this case, the rat receives a brief, mild electric shock. Finally, there is also a holding cage (separate from the experimental apparatus) available.
The learning takes place over a series of trials. The first trial goes something like this: The rat is placed in the compartment with the light bulb as shown below.
When the trial begins, three things happen. The door is raised, the light is turned on, and a stopwatch is started (see the diagram below).
Within a few seconds of the door being raised, the rat will typically sniff around and begin to move into the darker compartment (without the light). When the rat has completely entered the darker compartment, the door is closed and the brief, mild shock is administered. The goal is for the rat to learn not to move into the darker compartment. In other words, by remaining passive, the rat can avoid the shock, hence the term passive avoidance. For our purposes, we will use a criteria of 180 seconds as our operational definition of learning PA. That is, when the rat remains in the brightly lit compartment for 3 minutes, we will say that it has learned the task and what we measure is the number of trials it takes the rat to do this. (Note that a "smart" rat will take less trials to learn.) Thus, the PA task was chosen as the DV because it can be thought of as a measure of "self restraint."
Now let's discuss the types of information this design can yield. There are three types:
 Factor A  addresses whether maternal diet effects PA learning.
 Factor B  addresses whether age is related to PA learning.
 AxB Interaction  addresses whether the effects of maternal diet depend on the age of the offspring.
More generally, we speak of several kinds of effects:
 Treatment Effect  a difference in population means. There are two kinds:
 Main Effect  a difference in population means for a factor collapsed over the levels of all other factors in the design.
 Interaction Effect occurs when the effect on one factor is not the same at the levels of another.
Thus a two way factorial design tells us about two main effects and the interaction.
Let's consider all of the possible outcomes that could occur in the example introduced above. This will help us to better understand the effects involved in general and the concept of an interaction in particular. There are eight possibilities for what could occur. In other words, there are eight possibilities of what could be significant in the analysis. That is:
Let's consider each of these possibilities in detail. We'll present the means in a table along with the marginal means (which make the main effects easier to see) as well as in the format of a figure. For this educational exercise, we need to make a silly assumption so that we won't have to deal with raw data and computational analysis. We will assume that a difference in means of two trials is significant. Normally we would need the raw data and have to perform the statistical computations to determine what is significant. To save lots of time and be able to concentrate on the important ideas involved, we will go with this arbitrary and silly assumption of a two trial difference necessary for statistical significance.
1. The first possibility is that nothing is significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 3 3 3 (35% EDC) 3 3 3 B marginals3 3
The fact that neither the cell means nor the marginal means show any differences tell us that nothing is significant. In graphical form:
2. The second possibility is that the main effect of factor A is significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 2 2 2 (35% EDC) 4 4 4 B marginals3 3 Notice that the A marginals show a difference of two and thus the main effect of factor A is significant. The animals receiving alcohol in utero took more trials to learn PA than controls. The fact that the effect is consistent across both levels of factor B tells us that there is no interaction. In graphical form:
3. The next possibility is that the main effect of factor B is significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 4 2 3 (35% EDC) 4 2 3 B marginals4 2 Notice that the B marginals show a difference of two and thus the main effect of factor B is significant. The older animals took fewer trials to learn PA than the younger animals. The fact that the effect is consistent across both levels of factor A tells us that there is no interaction. In graphical form:
4. The next possibility is that both main effects are significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 3 1 2 (35% EDC) 5 3 4 B marginals4 2 Notice that both sets of marginals show a difference of two and thus main effects are significant. The animals receiving alcohol in utero took more trials to learn PA than controls and the older animals took less trials to learn PA than the younger animals. The fact that both of these main effects are consistent across the levels of the remaining factor tells us that there is no interaction. In graphical form:
5. The next possibility is that the interaction is significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 2 4 3 (35% EDC) 4 2 3 B marginals3 3 Notice that both sets of marginals show no difference, thus neither main effect is significant. However, some of the cell means do differ by two. The animals receiving alcohol in utero took more trials to learn PA when young and less when older than controls. In other words, the effects of prenatal alcohol depended on the age of the animal when tested. Whenever the effect of one factor depends upon the levels of another, there is an interaction. In graphical form:
6. The next possibility is the interaction and the main effect of factor A are significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 1 3 2 (35% EDC) 5 3 4 B marginals3 3 Notice that the B marginals show no difference, thus the main effect of B is not significant. The A marginals do show a difference of two which demonstrates a main effect of factor A. This tells us that the animals that received alcohol in utero took longer to learn PA than the animals that didn't. However, the cell means tell the real story here. That is, the effect depends on age. The animals receiving alcohol in utero took more trials to learn PA when young but were normal when older when compared to controls. In graphical form:
One famous statistician (Keppel) has noted something to the effect that when there is an interaction along with main effects, we must reexamine the main effects to see if they are really worth paying attention to. In other words, an interaction can override any main effects. Thus, let us reexamine the main effect in the present case. It says that animals that received alcohol in utero took longer to learn PA than the animals that didn't. However, when looking at the cell means we see that this is only the case for the younger animals. Thus, in this case, the interaction overrides the main effect. In other words, it gives us a more accurate picture of what is actually occurring.
7. The next possibility is that the interaction and main effect of factor B are significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 3 3 3 (35% EDC) 5 1 3 B marginals4 2 Notice that the A marginals show no difference, thus the main effect of A is not significant. The B marginals do show a difference of two which demonstrates a main effect of factor B. This tells us that younger animals took longer to learn PA than older animals. However, the cell means tell the real story here. That is, the improvement with age only occurs for animals receiving alcohol in utero. In graphical form:
Given that there is an interaction along with a main effect, we must reexamine the main effect to see if it is worth paying attention to. The main effect says that older animals learn more quickly than young ones. However, when looking at the cell means we see that this is only the case for animals receiving alcohol in utero. Thus, in this case, the interaction overrides the main effect.
8. The next possibility is that the interaction and both main effects are significant. Here is one possible representation of this outcome.
Age (factor B) A
marginalsAdolescent Adult Maternal Diet
(factor A)(0% EDC) 1 1 1 (35% EDC) 5 1 3 B marginals3 1 The main effect of A (seen in the A marginals as usual), tells us that the animals receiving alcohol in utero took more trials to learn than controls. The main effect of factor B tells us that adults learned more quickly than younger animals. However, the cell means tell the real story here. That is, the interaction tells us that the effect of alcohol depended upon age. For the younger animals, animals receiving alcohol in utero showed impaired learning compared to controls while this deficit was not observed in adults. In graphical form:
Given that there is an interaction along with the main effects, we must reexamine the main effects to see if they are really worth paying attention to. The main effect of factor A says that animals receiving alcohol in utero showed impaired learning compared to controls. However, the cell means (i.e., the interaction) show that this is not always the case. The main effect of factor B says that adults learned more quickly than younger animals, but this too is not always the case. Thus, the interaction is what is important here. By the way, this outcome is in essence what the investigators actually observed.At this point, you might be wondering if there is ever a situation where a main effect and interaction are significant and the main effect is still worth paying attention to. The diagram below presents such a scenario.
In this case, there is a main effect of factor A (maternal ethanol) and an interaction. The main effect says that animals receiving alcohol in utero took more trials to learn than controls. Even though the interaction (which says that the effect is greater in young animals) is significant, the main effect is also worth paying attention to because it holds true at all levels of factor B.
There are three important advantages to the factorial design:
 Economy
The design provides more information from the same amount of work. Consider the effects of marijuana on memory. We have an experimental group that receives the drug and a control group that receives a placebo.
Two Group Design Control Experimental n=10 n=10
Factorial Design Control Experimental naive n=5 n=5 experienced n=5 n=5 n=10 n=10 Although the number of subjects is the same in both designs, with the factorial design, we obtain the additional information about the relationship of previous experience with the drug to memory performance.
 Experimental Control & Increased Generality of the Results
Suppose we are interested in the effects of teaching method on student performance. A potential extraneous variable in this case is the IQ of the students. The EV inflates the error term (i.e., the within group variability). One way to deal with this problem is to employ subjects with a homogeneous IQ. A more elegant solution is to include IQ as a factor in the design and thus remove this added source of variability from the error term.
Teaching Method A B C IQ Low Medium High An additional potential advantage of this approach is that the results have more generality (they apply to folks of varying IQs).
 The Interaction
The factorial design is the only way that we can investigate the interactions among IVs. This is particularly important because the effect of an IV rarely occurs in isolation. In the real world, many variables operate simultaneously. Thus, the factorial design allows us to investigate these more realistic situations.
In the two way factorial design, there is one possible interaction. We have discussed the notion of the interaction in detail above. In a three way factorial design, there are four possible interactions, that is: A x B, A x C, B x C, and the triple interaction, A x B x C. Triple interactions are beyond the scope of this course and thus will not be discussed further.
Any  Last  
Score 



Factor A 



Factor B 


only thing new 
So p equals the number of levels of factor A and q equals the number of levels of factor B.
Thus:
Factor B  A Marginals 


b_{1}  b_{2}  b_{k}  b_{q}  
Factor A 
a_{1}  X_{i11}  X_{i12}  X_{i1k}  X_{i1q}  
X_{n11}  X_{n12}  X_{n1k}  X_{n1q}  
a_{2}  X_{i21}  X_{i22}  X_{i2k}  X_{i2q}  
X_{n21}  X_{n22}  X_{n2k}  X_{n2q}  
a_{j}  X_{ij1}  X_{ij2}  X_{ijk}  X_{ijq}  
X_{nj1}  X_{nj2}  X_{njk}  X_{njq}  
a_{p}  X_{ip1}  X_{ip2}  X_{ipk}  X_{ipq}  
X_{np1}  X_{np2}  X_{npk}  X_{npq}  
B Marginals 

Grand Mean 
So, a Cell Mean is computed as:
And a T or with a period in the subscript means to collapse over that factor (with the position of the subscript telling which factor to collapse). Thus, in the table above, the A marginals are shown in burgandy and the B marginals are shown blue.
Note that the grand N=npq. Also note that since the calculations become much more difficult with unequal ns, we will only cover the situation of equal ns.
The logic of the two way ANOVA is a direct extension of the one variable case. For the one variable case, we partitioned the total variability into two pieces. In terms of the Sum of Squares:
In the two way ANOVA, there will be a source of variance for each effect as well as the error term. In terms of the Sum of Squares:
Thus, there are five deviations involved:
For SS_{A}, we are interested in the deviations of the A marginals about the grand mean. In symbols:
For the actual formula, we need to square and sum these deviations over all subjects.
For SS_{B}, we are interested in the deviations of the B marginals about the grand mean. In symbols:
For the actual formula, we need to square and sum these deviations over all subjects.
For SS_{within}, we are interested in the deviations of the individual scores from their cell means. In symbols:
For the actual formula, we need to square and sum these deviations over all subjects.
For SS_{AxB}, we are interested in the deviations of the cell means from the grand mean minus the effects of factors A and B. In symbols:
This reduces to:
or, more simply:
For the actual formula, we need to square and sum these deviations over all subjects.
For SS_{T}, we are interested in the deviations of the individual scores from the grand mean. In symbols:
For the actual formula, we need to square and sum these deviations over all subjects.
And for the degrees of freedom, we have:
df_{A} =p1 df_{B} =q1 df_{AxB} =(p1)(q1)
=pqpq+1df_{within} =pq(n1)
=pqnpq
=Npqdf_{T} =npq1
=N1
In Symbols In Words H_{O} Prenatal alcohol has no effect on PA. H_{A} Not H_{o} Prenatal alcohol does have an effect on PA.
Factor B:
In Symbols In Words H_{O} Age is unrelated to PA learning. H_{A} Not H_{o} Age is related to PA learning.
A x B Interaction:
In Symbols In Words H_{O} The effect of alcohol
does not depend on age.H_{A} Not H_{o} The effect of alcohol
does depend on age
df_{A} =p1 =21 =1 df_{B} =q1 =21 =1 df_{AxB} =(p1)(q1)
=pqpq+1=(21)(21) =1 df_{within} =pq(n1)
=pqnpq
=Npq=2*2(51) =16 df_{T} =npq1
=N1=(5*2*2)1 =19
Notice that the df add up to the total. This info allows us to create a grid showing the critical values for the F ratio (obtained from the F table):
Source A B AxB df 1/16 1/16 1/16 F_{crit} 4.49 4.49 4.49
The 2x2 case is simple, that is, all three critical values are the same. If F_{obs} ≥ F_{crit}, reject H_{o}. Otherwise do not reject H_{o}.
Here is the data (i.e., the number of trials to learn PA):
Age > 
_{Young} b_{1 } 
_{Older} b_{2} 


Maternal Diet > 
0% a_{1} 
35% a_{2} 
0% a_{1} 
35% a_{2} 
Data  5  18  6  6 
4  19  7  9  
3  14  5  5  
4  12  8  9  
2  15  4  3  
18  78  30  32  
n=n_{jk}  5  5  5  5 
3.6  15.6  6  6.4 
The relevant descriptive statistic is the means, and, in the case of an ANOVA, it is probably best to plot them:
Let's expand on the data grid for the calculations.
Age > b_{1} b_{2} Maternal Diet > a_{1} a_{2} a_{1} a_{2} Data X X^{2} X X^{2} X X^{2} X X^{2} 5 25 18 324 6 36 6 36 4 16 19 361 7 49 9 81 3 9 14 196 5 25 5 25 4 16 12 144 8 64 9 81 2 4 15 225 4 16 3 9 18 78 30 32 158 T n=n_{jk} 5 5 5 5 20 N 3.6 15.6 6 6.4 70 1250 190 232 1742 II The following "totals table" helps with computing marginal totals.
b_{1} b_{2}a_{1} 18 30 48T_{j.}s a_{2} 78 32 110 96 62 158T_{.k}s T_{..} Now we will need five quantities. Note, in the interest of saving some space, all intermediate quantities are not shown. All steps are shown in the practice problems.
I.  

II.  
III.  
IV.  
V. 
And now we can compute the SS's:
SS_{A}=  IIII=  1440.41248.2=  192.2 
SS_{B}=  IVI=  1306.01248.2=  57.8 
SS_{AxB}=  V+IIIIIV=  1666.4+1248.21440.41306.0=  168.2 
SS_{W}=  IIV=  1742.01666.4=  75.6 
SS_{T}=  III=  1742.01248.2=  493.8 
We check that the Sum of Squares add up to the total and they do. Thus, remembering that:
and
We can fill in the ANOVA summary table:
Source  SS  df  MS  F  p 

A  192.2 
1 
192.2 
40.68  ≤.05 
B  57.8 
1 
57.8 
12.23  ≤.05 
AxB  168.2 
1 
168.2 
35.60  ≤.05 
Within  75.6 
16 
4.725 

Total  493.8 
19 
Note that given this pattern of data (which are fictitious but based upon fact), we would not pay attention to the main effects. The main effect of age is not true for the 0%EDC animals. The main effect of alcohol is not true for the adult animals. Thus, the interaction is what is worth paying attention to in this study.
In the example we have given of the 2x2 ANOVA, the outcome is clear. However, what if we had employed a 3x3 factorial design? That is, we include another control group that receives a normal, Lab Chow (LC) diet and we test the animals at either 30, 80, or 130 days of age. There are two types of analysis that should be mentioned here. I should note that in an effort to keep things simple, I will not ask you to actually perform these analyses. However, they follow logically from what we have been doing and it is certainly worth your while to be aware of their existence.
If there was no interaction and a significant main effect, we could do an analysis similar to what we did when using the protected t test with the one way ANOVA. Below is a formula to determine the Least Significant Difference (LSD) between means that is worthy of our attention. The procedure is essentially the same as for the protected t, however, in this case, the main effect is reflected in the marginal means which changes the formula slightly, and we are computing an LSD rather than an F ratio which also shifts things around a bit.
Consider the hypothetical example below:
In this case, the analysis would reveal that the significant main effect of maternal diet is due to the fact that the animals receiving alcohol in utero took longer to learn PA that did controls (which did not differ among themselves).
If, however, the interaction was significant, we might want to look at the simple main effects of the interaction. This analysis looks at the difference between the cell means for one factor at each of the levels of the other. The least significant difference between the means is computed with a slight modification to the formula we used above, that is:
The hypothetical data presented below (which, in this case, is based on the actual data obtained in the experiment) shows a significant interaction.
Computing the simple main effects of the interaction would show that the animals receiving alcohol in utero took significantly longer to learn PA at 30 days of age. At 80 days, the effect was marginal and at 130 days there was no effect. Furthermore, the analysis would show that the two control groups were not significantly different at any age.