# Part 11: Two-way ANOVA

### Principle and Application of two-way ANOVA

Please read the chapter on one-way ANOVA to learn the principle of ANalysis Of VAriance. The two-way ANOVA is an extension to the one-way ANOVA. There are two independent variables (hence the name two-way).

We havee three sets of hypothesis with the two-way ANOVA. The null hypotheses for each of the sets are given below. We use a two-way ANOVA when we have one measurement variable and two nominal variables. The nominal variables (often called „factors“ or „main effects“) are found in all possible combinations. For example, let’s say we are testing the null hypothesis that stressed and unstressed rats have the same glycogen content in their gastrocnemius muscle, and we are worried that there might be sex-related differences in glycogen content as well. The two factors are stress level (stressed vs. unstressed) and sex (male vs. female).

H0: The population means of the first factor are equal. This is like the one-way ANOVA for the row factor.
H0: The population means of the second factor are equal. This is like the one-way ANOVA for the column factor.
H0: There is no interaction between the two factors. This is similar to performing a test for independence with contingency tables.

Factors
The two independent variables in a two-way ANOVA are called factors. The idea is that there are two variables, factors, which affect the dependent variable. Each factor will have two or more levels within it, and the degrees of freedom for each factor is one less than the number of levels. For example, we can consider the effectiveness of drug A and drug B in treated abnormal hormone levels. Each drug is a factor.

Treatment Groups
Treatment groups are formed by making all possible combinations of the two factors. For example, if the first factor has 3 levels and the second factor has 2 levels, then there will be 3×2=6 different treatment groups.

Interaction
There is an interaction between two factors if the effect of one factor depends on the levels of the second factor. When the two factors are identified as A and B, the interaction is identified as the A X B interaction.

What are interaction effects? Here are some substantive examples:

• Drugs A and B may have no effect when either is taken alone. But, the two together may have an effect.
• We might find that greater income leads to greater spending in cars for those who like cars, and lower spending for those who do not have a special interests in cars. We say that the effect of income is dependent on desires, or that desires and income interact in determining spending on cars.
• Good teachers and small classrooms might both encourage learning. A good teacher in a small classroom might be especially effective. The whole is greater than the sum of the parts.

### How to arrange data for two-way ANOVA?

This can be tricky, and for this reason MaxStat has a built-in template to arrange the data correctly. In the following image data from the example 12.1 in Zar’s book „Biostatistical Analysis“ (2010, p.250-255) is shown. We want to test if plasma calcium concentration (mg/100 ml) of male and female birds is affected by hormone treatment.

The hypotheses are:

Ho1: No effect of hormone treatment on the mean plasma calcium concentration of birds.
Ha1: There is an effect of hormone treatment on the mean plasma calcium concentration of birds.

Ho2: No difference in the mean plasma calcium concentration between male and female birds.
Ha2: There is a difference in the mean plasma calcium concentration between male and female birds.

Ho3: No interaction of sex and hormone treatment on the mean plasma calcium concentration of birds.
Ha3: There is an interaction of sex and hormone treatment on the mean plasma calcium concentration of birds.

As we can see from the results (image below), the F-statistic for the null hypotheses of no interaction (Ho3) is not
significant (p-value = 0.6170 > 0.05). The F-statistic for the null hypothesis of no difference between sexes (Ho2) is also not significant (p = 0.0713 > 0.05). However, the F-statistic for the null hypothesis of no treatment effect (Ho1) is highly significant ( p < 0.0001 << 0.05). Thus, we conclude that hormone treatment affects the plasma calcium concentration in this sample of birds.

### Two-way ANOVA with repeated measures on one factor

A two-way ANOVA may be done with repeated measurements or replications (more than one observation for each combination of the nominal variables) on one factor, i.e. two independent variables (factors) are regulated to just one of the treatment factors. Let us consider an example with data from Keppel & Wickens (2004), Table 19.4, p. 439:
Three groups of kangaroo rats (factor A) were tested in environments with different numbers of landmarks (factor B). The scores are the percentage of cached seeds recovered one day later. Factor “A” has three levels and represents the between-subjects factor. Factor “B” has four levels and represents the within-subjects factor. In each group (level) of factor A, there are four different subjects, each measured a total of four times. The following table illustrate and shows how to arrange the data for the above described example.

### Two-way ANOVA with repeated measures on both factors

Repeated measures on both factors means that each subject is investigated with all of the treatment conditions. In contrast to the repeated measures on one factor, in this analysis each subject appear at all levels of each factor.

### Post comparison tests

Similar to one-way ANOVA, we need to apply a post comparison test to find out where the differences among the sample population occur. MaxStat supports the following post comparison tests for two-way ANOVA: Bonferroni, Dunnett, Tukey, Scheffe and Fisher-LSD test.