ANOVA
Comparing two means is easy. Comparing three or more at once — without inflating your error rate — requires Analysis of Variance. One elegant F-test to rule them all.
The Multiple Testing Trap
Running 6 t-tests at α = 0.05 each raises the familywise error to 1 − 0.95⁶ ≈ 26%. ANOVA keeps it at 5% with one test.
Partitioning SS
SSB is the signal (group means differ from grand mean). SSW is the noise (observations scatter within each group).
The F-Statistic
Under H₀, F ≈ 1. Under H₁ (some means differ), MSB grows but MSW stays put → F > 1. Reject H₀ when F exceeds the critical value F*(k−1, N−k).
The ANOVA Table
- Between: SSB, df = k−1, MSB = SSB/(k−1)
- Within: SSW, df = N−k, MSW = SSW/(N−k)
- Total: SSₜ, df = N−1
- F = MSB / MSW with p-value from F(k−1, N−k)
ANOVA Assumptions
- Normality within each group (QQ plot, Shapiro-Wilk)
- Equal variances across groups (Levene’s test; max s ≤ 2× min s)
- Independence of observations within and across groups
Unequal variances → Welch’s ANOVA
Post-Hoc Tests
Tukey’s HSD: best for all pairwise comparisons, equal n. Bonferroni: use adjusted α = 0.05/m for any pre-planned set of m comparisons.
Two-Way ANOVA
Three simultaneous F-tests: main effect A, main effect B, and interaction AB. Each uses MSE (residual) as the denominator.
Interaction Effects
- Effect of A depends on which level of B you’re in
- Visualize: non-parallel lines in an interaction plot
- Crossing lines = strong interaction (can reverse direction)
- When significant, do not interpret main effects alone
Kruskal-Wallis
Rank all N observations jointly. H ∼ χ²(k−1) under H₀. No normality assumption. Post-hoc: Dunn’s test with Bonferroni.
What you learned
- ANOVA compares k ≥ 3 means with one F-test, controlling familywise error
- F = MSB/MSW — between-group signal over within-group noise
- Assumptions: normality, equal variances, independence
- Post-hoc: Tukey’s HSD or Bonferroni to find which pairs differ
- Two-way ANOVA adds interaction — check it before main effects
- Kruskal-Wallis: rank-based alternative when normality fails