ANOVA
Overview
ANOVA partitions total variance in the data into between-group variance (differences attributable to the treatment) and within-group variance (random noise within groups). The F-statistic is the ratio of between-group to within-group variance: . A large F indicates that group means are more spread than expected by chance. One-way ANOVA tests means across levels of a single factor. Two-way ANOVA tests two factors and their interaction. ANOVA is an omnibus test β it only tells you that at least one group differs, not which groups differ. Post-hoc tests (Tukey's HSD, Bonferroni) identify specific pairwise differences after a significant F-test.
Key Concepts
ANOVA Assumptions
- Independence: Observations are independent within and across groups. Violations (e.g., repeated measures) require different tests.
- Normality: Residuals are approximately normally distributed. Robust to violations with large (CLT).
- Homogeneity of variances: Groups have equal population variances. Test with Levene's test. If violated, use Welch's ANOVA.
Sum of Squares Decomposition
- : Variation due to group differences (explainable)
- : Variation within groups (unexplainable noise)
- : Proportion of total variance explained by groups
Post-Hoc Tests
| Test | When to Use | Controls | Conservativeness |
|---|---|---|---|
| Tukey's HSD | All pairwise comparisons | Family-wise error | Moderate |
| Bonferroni | Few planned comparisons | Family-wise error | Conservative |
| Scheffe | All possible contrasts | Family-wise error | Most conservative |
| Dunnett | Each group vs. control | Family-wise error | Moderate |
Quick Example
Assumption Checking in Python
from scipy import stats
# Levene's test for equal variances
_, p_levene = stats.levene(group1, group2, group3)
print(f"Levene's test p-value: {p_levene:.3f}")
# Shapiro-Wilk test for normality of residuals
_, p_normal = stats.shapiro(residuals)
print(f"Normality test p-value: {p_normal:.3f}")
If Levene's test is significant (), use Welch's ANOVA or the nonparametric Kruskal-Wallis test instead.
Key Takeaways
Deep Dive
For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:
ANOVA
- One-Way ANOVA β Complete derivation, F-distribution, sum of squares decomposition, post-hoc tests, and Python implementation
Related Tests
- F-Test for Equality of Variances β Testing whether two groups have equal variances using the F-distribution
- Levene's Test β Robust test for homogeneity of variances when normality is questionable
- Two-Sample t-Test β ANOVA with 2 groups is equivalent to a t-test ()
Related Topics
- Hypothesis Testing β The framework underlying ANOVA
- Multiple Testing Problem β Why post-hoc corrections are necessary
- Bonferroni Correction β Controlling family-wise error rate
- Nonparametric Methods β Kruskal-Wallis as the nonparametric alternative to ANOVA
- Effect Size β Measuring practical significance alongside statistical significance