ANOVA without equal variances
Welch's ANOVA, Brown–Forsythe's F*, Alexander–Govern and trimmed-means ANOVA, and how to choose among them before you see the data.
What runs in CodeSplash
- STAT014Welch ANOVA Runs in CodeSplash
- STAT015Brown–Forsythe mean comparison test Runs in CodeSplash
- STAT016Alexander–Govern test Runs in CodeSplash
- STAT020Welch type trimmed mean ANOVA Runs in CodeSplash
- One-way ANOVA (Welch / classic) Verified in Python and R
- Trimmed-means ANOVA (Welch-type, robust) Verified in Python and R
You will be able to
- Explain how pooled variance fails when spreads and sizes differ
- Distinguish the Welch, Brown–Forsythe and Alexander–Govern tests
- Choose trimmed-means ANOVA for heavy tails, and name its estimand
Read first
Where the pooled F breaks
ReadThe classic F uses one pooled variance for every group. When the groups have different spreads, a pooled estimate is wrong for all of them. If the smallest group is also the noisiest, F rejects a true null far too often.
Welch's correction, which you met for two groups, generalizes to several.
Break it
ExploreGive the smaller group the larger spread, then swap them. Watch how the Type I error rate of the pooled test moves away from 5%, and how Welch's stays close.
BExplorable · Student's t against Welch's t
When the group variances differ, which t test keeps its promised 5% error rate?
When the smaller group has the larger SD, Student's t (pooled variance) rejects a true null…
Commit your prediction above to see the result
Make your prediction to see the result.
Welch's ANOVA
ReadWelch weights each group by its precision, , and compares means to a precision-weighted grand mean:
On PlantGrowth, Welch gives F(2, 17.1) = 5.18, p = .017; the classic F gives F(2, 27) = 4.85, p = .016. With similar spreads they agree, and the cost of choosing Welch is small.
Two relatives
ReadBrown–Forsythe F* keeps the ordinary grand mean and changes only the denominator. On the chick feeds, F*(5, 58.7) = 15.52. Don't confuse it with the Brown–Forsythe test of variances; they share only their authors. CodeSplash's headline uses the original numerator df; it also reports Mehrotra's correction, which adjusts that df (here 4.60). statsmodels' primary p-value is the Mehrotra version, so say which one you report before comparing Python and R.
Alexander–Govern converts each group's t to a normal score and adds up the squares, referring the sum to .
On a three-group example, F* gives p < .001 and Alexander–Govern gives p = .001.
Heavy tails need another fix
PredictPredict first
A group has a few extreme values. Will switching from the classic F to Welch's protect you from them?
Reveal
No. Welch still uses means and variances, and both are sensitive to extremes. Trimmed-means ANOVA replaces them with trimmed means and Winsorized variances: F(2, 21.3) = 7.29, p = .004, with robust effect = 0.55.
Choose before you look
Reflect| Your situation | Default |
|---|---|
| Groups may differ in spread | Welch's ANOVA |
| Strong outliers, heavy tails | Trimmed-means ANOVA |
| Random assignment, similar spread, equal sizes | Classic F is fine |
| Ordinal outcomes | Kruskal–Wallis (next lesson) |
Which row fits your own data, and could you have said so before seeing the means?
Check your understanding
CheckpointCheck yourself
You have no strong reason to think three group variances are equal. What should you use by default?
Show the answer
Answer: a
Welch costs little when variances are equal and protects you when they aren't. Variance pretests are unreliable, and Kruskal–Wallis answers a different question.
Check yourself
A colleague says "Brown–Forsythe wasn't significant, so I'll use the classic F." Which Brown–Forsythe do they mean?
Show the answer
Answer: b
They mean the variance test, used as a pretest. F* tests means and is a replacement for the classic F, so check which one anyone means.
Check yourself
What does a trimmed-means ANOVA test?
Show the answer
Answer: b
The estimand changes with the method. Trimmed means coincide with means only for symmetric distributions.
Check yourself
A group has 30 values, trimmed by 10% in each tail. How many values does its trimmed mean average?
Show the answer
Answer: 24
Three go from each end, so 30 − 6 = 24 remain.
Check yourself
Three groups have similar spreads in their middles, but each has a few extreme values. Which is the best fit?
Show the answer
Answer: a
Welch deals with unequal variances, not with heavy tails. Removing values by hand ignores that you did so; trimming builds it into the standard error.
Do it in CodeSplash
In the appIn one-way ANOVA, Test offers Welch's ANOVA, Brown–Forsythe F*, Alexander–Govern and Classic F test. Post hoc comparisons defaults to Match the test. Trimmed-means ANOVA is its own method, with Bootstrap-t p-value for small samples.
import pandas as pd
from scipy import stats
from statsmodels.stats.oneway import anova_oneway
df = pd.read_csv("plantgrowth.csv")
print(anova_oneway(df["weight"], df["group"], use_var="unequal")) # Welch
print(anova_oneway(df["weight"], df["group"], use_var="bf")) # Brown-Forsythe F*; its primary p uses Mehrotra's df
groups = [g["weight"] for _, g in df.groupby("group")]
print(stats.alexandergovern(*groups))oneway.test(weight ~ group, data = PlantGrowth) # Welch
# install.packages(c("onewaytests", "WRS2"))
onewaytests::bf.test(weight ~ group, data = PlantGrowth)
onewaytests::ag.test(weight ~ group, data = PlantGrowth)
WRS2::t1way(weight ~ group, data = PlantGrowth, tr = 0.2)Recap
Recap- Unequal spreads break the pooled F, especially with unequal sizes. Welch's ANOVA is the safer default.
- Brown–Forsythe F* and Alexander–Govern solve the same problem in other ways.
- Heavy tails need trimmed means, and that changes what you are testing.
Concepts in this lesson