Chapter8 Multi-factor ANOVA

8.0.1 🧠Refresher🧠

A multi-factor ANOVA tests whether there are differnces between sample means, just like a regular ANOVA. However, there can be more than one factor governing which group an observation came from. A normal ANOVA can be used to determine whether “sense of belonging”, on average, differs between freshman, sophomores, juniors, and seniors. A regular ANOVA is appropriate if you want to determine whether average “sense of belonging” varies depending on gender. But what if you want to look at both factors: college level and gender? This would multiply the number of groups: male freshman, female freshman, male sophomore, female sophomore, etc.

A factorial ANOVA allows you to separate whether specific factors, by themselves, make some difference on the dependent variable. It also allows you to determine whether the factors “interact”: The effect of one factor depends on the other. An interaction in the class level by gender example would be if class level is associated with more sense of belonging, but only for women.

  • Factors: Factor \(A\) has \(a\) levels; Factor \(B\) has \(b\) levels
  • If Factor A is class level, then a = 4 (Freshman, Sophomore, Junior, Senior)
  • If Factor B is gender, then (for the purpose of this example), b = 2 (male, female)

The total variation (\(SS_{Total}\)) is the sum of the variation explained by each factor, their interaction, and the residual error:

\[ SS_{Total} = SS_A + SS_B + SS_{A\times B} + SS_{Residual} \]

8.0.2 Degrees of Freedom

  • \(df_A = a - 1\)
  • \(df_B = b - 1\)
  • \(df_{A\times B} = (a - 1)(b - 1)\)
  • \(df_{Total} = N_{Total} - 1\)
  • \(df_{Residual} = df_{Total} - df_A - df_B - df_{A\times B}\)

8.0.3 Mean Squares

The mean square (MS) for each source is the sum of squares divided by its degrees of freedom:

Source Formula
Factor A \(MS_A = \dfrac{SS_A}{df_A}\)
Factor B \(MS_B = \dfrac{SS_B}{df_B}\)
Interaction \(MS_{A\times B} = \dfrac{SS_{A\times B}}{df_{A\times B}}\)
Residual \(MS_{Residual} = \dfrac{SS_{Residual}}{df_{Residual}}\)

8.0.4 F-Statistics

The \(F\)-values for each main effect and the interaction are calculated by dividing the MS of the effect by the MS of the residual:

Effect Formula
Factor A \(F_A = \dfrac{MS_A}{MS_{Residual}}\)
Factor B \(F_B = \dfrac{MS_B}{MS_{Residual}}\)
Interaction \(F_{A\times B} = \dfrac{MS_{A\times B}}{MS_{Residual}}\)

8.0.5 💪Worked Example💪

Let’s say we have a 4 (Level: Freshman, Sophomore, Junior, Senior) × 2 (Gender: Male, Female) factorial design.

Since there are 4 levels of the first factor, its degrees of freedom will be:
\[ df_{Level} = 4 - 1 = 3 \]

Since there are 2 levels of the second factor, its degrees of freedom will be:
\[ df_{Gender} = 2 - 1 = 1 \]

For the interaction, we multiply the dfs:
\[ df_{Level \times Gender} = 3 \times 1 = 3 \]

The total degrees of freedom depend on the total number of observations. To keep it simple, let’s say we have 5 participants per group:
\[ N = 4_{Levels} \times 2_{Genders} \times 5_{Per\ group} = 40 \]

Since the total \(N = 40\), the total degrees of freedom are:
\[ df_{Total} = 40 - 1 = 39 \]

I’ll provide the sum of squares (SS) values — let’s say they add up to 100. Using those, can you figure out the MSs, and F-values for each source of variance?

Source SS df MS F
Level 25 3
Gender 10 1
Level × Gender 15 3
Residual (Error) 50 32
Total 100 39

First, we’re going to divide each SS by its corresponding df. The only exceptions is the Total:

Source SS df MS F
Level 25 3 8.33
Gender 10 1 10.00
Level × Gender 15 3 5.00
Residual (Error) 50 32 1.56
Total 100 39

Now we want to compare each source’s MS against the amount of error (residual) in the data. Do this by dividing each MS by the MS of the Residual (Erorr):

Source SS df MS F
Level 25 3 8.33 5.34
Gender 10 1 10.00 6.41
Level × Gender 15 3 5.00 3.21
Residual (Error) 50 32 1.56
Total 100 39

Each of these F-values comes with a specific numerator df — 3 for Level, 1 for Gender, and 3 for the interaction. They all share the same denominator df of 32, from the Residual (Error) term. F-values all have associated p-values (so long as the two dfs are specified too). In this case, the approximate p-values are: .004 for Level, .017 for Gender, and .036 for their interaction. Since all of these are below .05, they are all statistically signfiicant!

8.0.6 📝Homework problems📝

In these homework problems (and in all the preceding eqeuations) the sample sizes are assumed to be equal. This is because the math gets trickier when they’re unequal. The general principle behind the calculations remain the same though.

  1. An ANOVA output shows \(df_A=3\), \(df_B=2\), \(df_{A\times B}=6\), and \(df_{Total}=59\).
    1. How many levels (groups) are there for factor A and B?
    2. What is the total sample size of the study?
    3. What is df for the residuals?
    4. How many groups were their in this study overall?



  1. Given \(SS_{Total}=260.00\), \(SS_A=84.00\), \(SS_B=20.00\), \(SS_{Residual}=132.00\).
    1. Compute \(SS_{A\times B}\).
    2. If \(a=4\), \(b=3\), and \(n_{\text{cell}}=5\), fill the ANOVA table (dfs, MSs, and all Fs).
Source SS df MS F
Factor A 84.00
Factor B 20.00
A × B ___
Within (Error) 132.00
Total 260.00



  1. For a study with \(a=3\), \(b=3\), sample size of each group = 6:
    \(MS_{Within}=4.0\), \(SS_A=72.0\), \(SS_B=18.0\), \(SS_{A\times B}=12.0\).
    1. Compute all dfs, \(SS_{Within}\), and \(SS_{Total}\).
    2. Compute \(MS_A, MS_B, MS_{A\times B}\) and the three F-ratios.


Source SS df MS F
Factor A
Factor B
A × B Interaction
Within (Error)
Total



  1. We have a balanced two-way ANOVA, \(a=2\), \(b=5\), sample size for each group = 10. You are given: \(F_A=8.0\) and \(MS_{Within}=3.2\).
    1. Find \(MS_A\) and \(SS_A\).
    2. Compute all dfs, and then \(df_{Total}\).
      (Hint: \(MS_A = F_A \times MS_{Within}\); \(SS_A = MS_A \times df_A\).)


Source SS df MS F
Factor A
Factor B
A × B Interaction
Within (Error)
Total



  1. Minimal table completion
    A balanced design has \(a=3\), \(b=4\), sample size for each group = 5. The sums of squares are:
    \(SS_A=45.00\), \(SS_B=60.00\), \(SS_{A\times B}=24.00\), \(SS_{Within}=216.00\).
    Complete the table (dfs, MSs, and Fs):


Source SS df MS F
Factor A 45.00
Factor B 60.00
A × B 24.00
Within (Error) 216.00
Total ___