ANOVA - Analysis of Variance
What is ANOVA?
ANOVA (Analysis of Variance) is a statistical test used to compare the means of three or more groups to determine if at least one group mean is significantly different from the others. It was developed by Ronald A. Fisher in the 1920s.
Key idea: ANOVA partitions total variability in data into components - variability between groups vs. variability within groups.
The Core Logic
ANOVA tests the null hypothesis:
H₀: All group means are equal (μ₁ = μ₂ = μ₃ = ...)
H₁: At least one group mean is different
It uses the F-statistic:
F = Variance Between Groups / Variance Within Groups
= Mean Square Between (MSB) / Mean Square Within (MSW)
- A large F means between-group variance >> within-group variance → likely a real effect
- A small F (near 1) means the groups are not meaningfully different
Key Assumptions
- Normality - data within each group is approximately normally distributed
- Homogeneity of variance - groups have roughly equal variances (tested with Levene's test)
- Independence - observations are independent of each other
- Random sampling - data is drawn randomly
ONE-WAY ANOVA
One independent variable (factor) with 3+ levels.
Example
You test the effect of three teaching methods (A, B, C) on exam scores.
| Method A | Method B | Method C |
|---|
| 78 | 85 | 90 |
| 82 | 88 | 92 |
| 75 | 80 | 87 |
| 79 | 83 | 91 |
Steps:
- Calculate group means: A = 78.5, B = 84, C = 90
- Calculate Grand Mean = mean of all values
- Compute Sum of Squares Between (SSB) - how much group means deviate from grand mean
- Compute Sum of Squares Within (SSW) - how much individual values deviate from their group mean
- Divide by degrees of freedom to get MSB and MSW
- Compute F = MSB / MSW
- Compare F to the critical F-value from an F-distribution table (or get p-value)
Decision: If p < 0.05, reject H₀ - at least one teaching method produces different scores.
ANOVA Table Structure
| Source | SS | df | MS | F | p-value |
|---|
| Between | SSB | k-1 | SSB/df | MSB/MSW | ... |
| Within | SSW | N-k | SSW/df | | |
| Total | SST | N-1 | | | |
Where k = number of groups, N = total observations.
TWO-WAY ANOVA
Two independent variables (factors), examining their individual effects AND their interaction.
Example
You study the effect of Teaching Method (A, B, C) AND Class Size (Small, Large) on exam scores.
This lets you answer three questions:
- Does teaching method significantly affect scores? (Main effect 1)
- Does class size significantly affect scores? (Main effect 2)
- Does the effect of teaching method depend on class size? (Interaction effect)
Interaction Effect - The Most Interesting Part
An interaction exists when the effect of one factor changes depending on the level of the other.
Example:
Method A works better in small classes.
Method C works equally well regardless of class size.
→ Teaching method and class size INTERACT.
If an interaction is significant, you cannot interpret main effects in isolation.
Two-Way ANOVA Table
| Source | SS | df | MS | F |
|---|
| Factor A | SSA | a-1 | MSA | FA |
| Factor B | SSB | b-1 | MSB | FB |
| A × B Interaction | SSAB | (a-1)(b-1) | MSAB | FAB |
| Within (Error) | SSW | N-ab | MSW | |
| Total | SST | N-1 | | |
REPEATED MEASURES ANOVA
The same subjects are measured multiple times (across conditions or time points).
This is the within-subjects equivalent of one-way ANOVA - it accounts for the fact that measurements from the same person are correlated.
Example
You measure pain scores in 5 patients at 3 time points: Before treatment, 1 week after, 4 weeks after.
| Patient | Pre | Week 1 | Week 4 |
|---|
| P1 | 8 | 5 | 2 |
| P2 | 7 | 4 | 3 |
| P3 | 9 | 6 | 1 |
| P4 | 6 | 3 | 2 |
| P5 | 8 | 5 | 2 |
Why not use regular one-way ANOVA?
- Regular ANOVA assumes independence between groups
- Here, P1's Pre score and P1's Week 4 score are NOT independent - they're from the same person
- Repeated measures ANOVA removes subject-to-subject variability, giving more statistical power
Key Extra Assumption: Sphericity
- The variances of differences between all pairs of time points must be equal
- Tested with Mauchly's test
- If violated, apply corrections: Greenhouse-Geisser or Huynh-Feldt
POST-HOC TESTS
ANOVA only tells you "at least one group is different" - it does NOT tell you which groups differ. Post-hoc tests do pairwise comparisons while controlling for multiple testing error.
| Test | When to Use |
|---|
| Tukey's HSD | Equal group sizes, comparing all pairs |
| Bonferroni | Conservative, any number of comparisons |
| Scheffe | Most conservative, flexible comparisons |
| LSD (Fisher's) | Least conservative, small number of groups |
| Games-Howell | When variances are unequal |
When ANOVA Fails - Alternatives
| Situation | Alternative |
|---|
| Non-normal data, 3+ groups | Kruskal-Wallis test (non-parametric One-Way ANOVA) |
| Non-normal, repeated measures | Friedman test |
| Only 2 groups | Independent t-test or paired t-test |
Quick Comparison Summary
| Feature | One-Way | Two-Way | Repeated Measures |
|---|
| # of IVs | 1 | 2 | 1 (within-subjects) |
| Subjects | Different per group | Different per cell | Same across levels |
| Tests interaction? | No | Yes | No (unless mixed design) |
| Key extra assumption | - | - | Sphericity |
| Non-parametric alt. | Kruskal-Wallis | - | Friedman |
Bottom line: Use One-Way ANOVA when you have one factor with 3+ groups. Use Two-Way ANOVA when you want to study two factors and their interaction simultaneously. Use Repeated Measures ANOVA when the same subjects appear in multiple conditions - it's more powerful because it controls for individual differences.