Two-Way ANOVA — Definition, Formula & Example
Two-Way ANOVA is a test that compares group means when each observation is classified by two factors at once. It tells you whether each factor matters on its own and whether the effect of one factor changes depending on the level of the other.
For factor with levels, factor with levels, and observations per cell, two-way ANOVA partitions the total sum of squares as , with degrees of freedom , , , and . It tests three null hypotheses: all , all , and all . Each uses the statistic , which follows an F-distribution under its null hypothesis when the errors are independent and normal with equal variance.
Key Formula
Where:
- = The k-th observation in the cell with level i of factor A and level j of factor B
- = The overall (grand) mean
- = Main effect of level i of factor A
- = Main effect of level j of factor B
- = Interaction effect: the extra shift for that specific combination of levels
- = Random error, assumed independent and normal with mean 0 and constant variance
Worked Example
Problem: Students study with flashcards (FC) or practice tests (PT) for 1 hour or 3 hours, then take a 25-point quiz. Each cell has two students. FC, 1 hr: 9, 11. FC, 3 hr: 9, 11. PT, 1 hr: 11, 13. PT, 3 hr: 19, 21. Test both main effects and the interaction at .
Step 1: Find the means. The cell means are 10, 10, 12, and 20. Here . Average across rows, across columns, and overall.
Step 2: Compute the sums of squares. The interaction term for each cell is cell mean minus row mean minus column mean plus grand mean. For these data it is in every cell. Each score sits 1 point from its cell mean, so SSE is 8 with degrees of freedom.
Step 3: Each effect has 1 degree of freedom, so each mean square equals its sum of squares. Divide by MSE and compare each ratio to the critical value .
Answer: All three F-statistics exceed 7.71, so you reject all three null hypotheses. The significant interaction is the key finding. Extra study time raised practice-test scores by 8 points (12 to 20) but did not change flashcard scores at all (10 to 10). So you cannot describe the effect of study time without naming the method.
Why It Matters
Experiments in psychology, agriculture, and medicine often vary two treatments together, such as drug and dosage or fertilizer and watering schedule. Two-way ANOVA is the standard method for these factorial designs in a college statistics or experimental design course. Its interaction test is the standard way to detect that a treatment works for one group but not another.
Common Mistakes
Mistake: Reporting the main effects as the headline result when the interaction is significant.
Correction: A main effect averages over the other factor. In the example, the 4-point study-time effect is an average of 0 and 8, and it fits neither method. When the interaction is significant, compare the cell means within each level of the other factor instead.
