Contents     Contents Index APA Style Guide Dr. P's Place

Analysis of Variance - Two Way

  1. Introduction
    1. Design
    2. The Notion of an Interaction
    3. Advantages of the Factorial Design
  2. Notation
  3. Logic
  4. Formal Example
    1. Research Question
    2. Hypotheses
    3. Assumptions
    4. Decision Rules
    5. Computation - [Minitab]
    6. Decision
  5. Comparisons Revisited

Practice Problems (Answers)
Homework


I. Introduction

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.

  1. Design

    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.

  2.  
    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:

More generally, we speak of several kinds of effects:

Thus a two way factorial design tells us about two main effects and the interaction.

  1. The Notion of an 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:

    1. Nothing
    2. Main effect of factor A
    3. Main effect of factor B
    4. Both main effects (factors A and B)
    5. A x B interaction
    6. A x B interaction and main effect of factor A
    7. A x B interaction and main effect of factor B
    8. A x B interaction and both main effects (factors A and B)

    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.

  2.  
    Age (factor B)
    A
    marginals
    Adolescent
    Adult
    Maternal Diet
    (factor A)
    (0% EDC)
    3
    3
    3
    (35% EDC)
    3
    3
    3
    B marginals
    3
    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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
2
2
2
(35% EDC)
4
4
4
B marginals
3
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
4
2
3
(35% EDC)
4
2
3
B marginals
4
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
3
1
2
(35% EDC)
5
3
4
B marginals
4
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
2
4
3
(35% EDC)
4
2
3
B marginals
3
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
1
3
2
(35% EDC)
5
3
4
B marginals
3
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
3
3
3
(35% EDC)
5
1
3
B marginals
4
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
marginals
Adolescent
Adult
Maternal Diet
(factor A)
(0% EDC)
1
1
1
(35% EDC)
5
1
3
B marginals
3
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.

  1. Advantages of the Factorial Design

There are three important advantages to the factorial design:

  1. 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.

  2. 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.

  1. 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.

  2.  
    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).

  1. 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.


II. Notation
We already knew that:

Thus:

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.


III. Logic

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 SSA, 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 SSB, 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 SSwithin, 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 SSAxB, 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 SST, 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:

dfA =p-1
dfB =q-1
dfAxB =(p-1)(q-1)
=pq-p-q+1
dfwithin =pq(n-1)
=pqn-pq
=N-pq
dfT =npq-1
=N-1

IV. Formal Example
  1. Research Question
    There are several (corresponding to the effects in the analysis):
       Does prenatal alcohol affect PA learning in rats?
       Does PA learning change with age?
       Do the effects of prenatal alcohol depend on the age of testing?

  2. Hypotheses
    Since there are several research questions, we need a pair of hypotheses for each question. One problem is that we are going to have complications in terminology (i.e., too many μs). So let's use Greek letters. For example, let α = the main effect of A and β = the main effect of B. More specifically:

    Says α1 equals the mean for the population for all groups in the first level of factor A minus the mean of the total population of scores. If there is no effect, this should be equal to zero.

    Note also that:

    Thus:

    Factor A:
      In Symbols In Words
    HO Prenatal alcohol has no effect on PA.
    HA Not Ho Prenatal alcohol does have an effect on PA.

Factor B:

      In Symbols In Words
    HO Age is unrelated to PA learning.
    HA Not Ho Age is related to PA learning.

A x B Interaction:

      In Symbols In Words
    HO The effect of alcohol
    does not depend on age.
    HA Not Ho The effect of alcohol
    does depend on age
  1. Assumptions
    1. The null hypothesis.
    2. The groups are sampled randomly.
    3. The population distribution of the DV is normal in shape.
    4. The groups are independent. (Note that the factorial design can handle dependent conditions, but it is beyond the scope of this course.)
    5. The population variances are homogenous.
    6. n's are equal and greater than 1 (typically at least 5).
    7. Factors are fixed, that is, the experimenter purposely chose the levels of the IVs. (Given the introductory nature of the course and the fact that this is the most common scenario encountered, this issue will not be discussed further.)

  2. Decision rules
    We are going to work with a 2x2 factorial design with 5 subjects per group. Thus:
    dfA =p-1 =2-1
    =1
    dfB =q-1 =2-1
    =1
    dfAxB =(p-1)(q-1)
    =pq-p-q+1
    =(2-1)(2-1)
    =1
    dfwithin =pq(n-1)
    =pqn-pq
    =N-pq
    =2*2(5-1)
    =16
    dfT =npq-1
    =N-1
    =(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
    Fcrit
    4.49
    4.49
    4.49

The 2x2 case is simple, that is, all three critical values are the same. If Fobs ≥ Fcrit, reject Ho. Otherwise do not reject Ho.

  1. Computation - [Minitab]

    Here is the data (i.e., the number of trials to learn PA):

    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 -> b1 b2    
Maternal Diet -> a1 a2 a1 a2
Data  X X2 X X2 X X2 X X2
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=njk 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.

 
b1
b2
 
a1
18
30
48
Tj.s
a2
78
32
110
 
96
62
158
 
T.ks
  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.

And now we can compute the SS's:

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:

  1. Decision
    Since we have three research questions, we also have three decisions to make. Since all three Fobs values are greater than the Fcrit (i.e., 4.49), we reject Ho in each case.
    1. There is a main effect of prenatal alcohol which says that animals receiving alcohol in utero showed impaired passive avoidance learning when compared to controls.
    2. There is a main effect of age which says that mature animals learned the task more quickly.
    3. There is an interaction which says that prenatal alcohol produces a deficit in the ability to withhold responding which dissipates as the animal matures.

    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.


V. Comparisons Revisited

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.

  1. Further Analysis of Main Effects

    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).

  2. Simple Main Effects of the Interaction

    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.


Contents Index APA Style Guide Dr. P's Place Copyright © 1997-2016 M. Plonsky, Ph.D.
Comments? mplonsky@uwsp.edu.