7.9 Analysis of Variance
Key Takeaways
- ANOVA partitions total sum of squares into between-groups (treatment) and within-groups (error) components.
- The F statistic is the ratio of mean square treatment to mean square error, and a large F indicates that group means differ.
- ANOVA controls the family-wise error rate that repeated pairwise t-tests would inflate.
- A significant F test says that at least one mean differs but not which; post-hoc tests such as Tukey's HSD identify the pairs.
- ANOVA assumes independence, normality of residuals, and homogeneity of variances, and is most sensitive to violations of independence.
Why not repeated t-tests
With $k$ groups there are $k(k-1)/2$ pairwise comparisons. For five groups that is ten tests, and at $\alpha = 0.05$ per test the family-wise error rate is $1 - 0.95^{10} = 0.40$. ANOVA answers the question with a single test at the stated $\alpha$.
The partition
The logic: if the group means were all equal, the only reason group averages would differ is random error, so between-group variation would be about the same size as within-group variation. If treatment means genuinely differ, between-group variation is inflated.
The ANOVA table
| Source | Sum of squares | df | Mean square | F |
|---|---|---|---|---|
| Treatment (between) | $SS_{treat}$ | $k - 1$ | $MS_{treat} = SS_{treat}/(k-1)$ | $MS_{treat}/MS_{error}$ |
| Error (within) | $SS_{error}$ | $N - k$ | $MS_{error} = SS_{error}/(N-k)$ | |
| Total | $SS_{total}$ | $N - 1$ |
where $k$ is the number of groups and $N$ the total number of observations. Reject $H_0: \mu_1 = \mu_2 = \cdots = \mu_k$ when $F > F_{\alpha,,k-1,,N-k}$.
Note that $MS_{error}$ is the pooled estimate of the common within-group variance $\sigma^2$, and its square root is the standard deviation used for post-hoc comparisons.
Worked example
Four suppliers, five specimens each, tensile strength in MPa.
| Supplier | Observations | $\bar{y}_i$ |
|---|---|---|
| A | 412, 418, 415, 421, 414 | 416.0 |
| B | 428, 431, 425, 433, 428 | 429.0 |
| C | 409, 414, 411, 407, 414 | 411.0 |
| D | 424, 419, 427, 422, 423 | 423.0 |
Grand mean $\bar{y} = 419.75$, $N = 20$, $k = 4$.
Within-group sums of squares are 50.0, 38.0, 38.0, and 34.0, giving $SS_{error} = 160.0$.
| Source | SS | df | MS | F |
|---|---|---|---|---|
| Supplier | 933.75 | 3 | 311.25 | 31.13 |
| Error | 160.00 | 16 | 10.00 | |
| Total | 1093.75 | 19 |
$F_{0.05,3,16} = 3.24$, and $31.13 \gg 3.24$, so at least one supplier mean differs. The effect size is
so supplier accounts for 85.4% of the variation in tensile strength.
After a significant F
A significant $F$ says at least one mean differs; it does not say which. Post-hoc procedures control the family-wise error rate while making the pairwise comparisons:
| Procedure | Use |
|---|---|
| Tukey's HSD | All pairwise comparisons; the standard default |
| Dunnett's test | Comparing several treatments against one control only |
| Fisher's LSD | Least conservative; only defensible after a significant F, and even then criticized |
| Bonferroni | Simple and conservative; adjust $\alpha$ to $\alpha/m$ for $m$ comparisons |
| Scheffe | Most conservative; permits arbitrary contrasts decided after seeing the data |
Running post-hoc tests without a significant omnibus F reintroduces the error-rate inflation that ANOVA exists to prevent.
Assumptions
| Assumption | How to check | Effect of violation |
|---|---|---|
| Independent observations | Study design; residuals versus run order | Serious; invalidates the test |
| Residuals normally distributed | Normal probability plot of residuals; Anderson-Darling | Mild; ANOVA is robust with balanced designs and moderate n |
| Equal variances across groups | Levene's or Bartlett's test; residuals versus fits | Moderate; serious with unequal group sizes |
ANOVA is robust to moderate non-normality when the design is balanced, but it is not robust to dependence. Time-ordered data with autocorrelation, or observations clustered within batches, violate the assumption in a way no transformation fixes; the design must change.
Bartlett's test for equal variances is itself very sensitive to non-normality, so Levene's test is preferred in practice. Where variances differ materially, use Welch's ANOVA or transform the response. When normality fails badly, the Kruskal-Wallis test is the non-parametric alternative.
Residual analysis is the practical way to check all three at once: plot residuals against fitted values (equal variance), on a normal probability plot (normality), and against run order (independence).
Beyond one-way
| Design | Question |
|---|---|
| One-way | Does one factor with $k$ levels affect the response? |
| Two-way | Do two factors affect the response, and do they interact? |
| Randomized block | Does the factor matter, after removing a known nuisance source such as batch or day? |
| ANOVA within DOE | Which main effects and interactions in a factorial design are significant? |
The two-way case introduces the interaction term, which tests whether the effect of one factor depends on the level of the other. Interactions are frequently the most important finding in a Six Sigma analysis, because they are invisible to one-factor-at-a-time experimentation. This is the direct link between ANOVA and the Improve phase: the analysis of a factorial experiment is an ANOVA.
A one-way ANOVA on four suppliers with five specimens each yields SS treatment = 933.75 and SS error = 160.00. What is the F statistic?
A one-way ANOVA across five machines returns p = 0.003. What may be concluded?
Which ANOVA assumption violation is least amenable to correction and most damaging to the validity of the test?