Two means are compared with a t test. Three or more need something else, and the reason is subtler than it looks. This lesson explains why running all the pairwise tests fails, how analysis of variance replaces them with one test that asks a different question, why that test is an F, and what to do once it comes out significant. The ANOVA table of Lesson 8 is derived here from the ground up.
Ashanagar is an invented district. The statistics lessons use it for every worked example, so you meet the same households again as the ideas build: first as a list of numbers, then as a spread, then as a population to sample from.
It has 60 households, each with a monthly income in rupees. Unless a page says otherwise, those 60 are the whole population, and a “sample” means a few of them drawn at random. Where a page needs two variables, it uses a smaller set of 12 households with the head’s years of schooling beside income.
The figures are illustrative, made up once and fixed. They are not official statistics.
A t test at the 5% level raises a false alarm one time in twenty when there is nothing to find. Run two such tests on a pair of independent comparisons and the chance of at least one false alarm is 1 − 0.95² = 0.0975 (DSE 2015 asks exactly this). With k groups there are k(k − 1) ÷ 2 pairs, and the chances of at least one false alarm climb quickly: three pairs, ten pairs, forty-five. The more comparisons you run, the more likely something looks significant by luck.
Every group in every experiment has the same true mean, so any declared difference is a false alarm. The single F test keeps its promise, at about 5% whatever k is. Running every pairwise t test at 5% does not: with 5 groups there are 10 pairs, and 29% of experiments find a “difference”. The textbook formula 1 − 0.9510 = 40% is only an upper guide, because the pairs share groups and are not independent. Dividing the level by the number of pairs brings the false-alarm rate back under 5%.
Note two things in the lab. First, the plain formula 1 − 0.95m is not the real rate: pairs that share a group are positively linked, so for five groups the true rate is about 28% and not 40%. It is a guide, and for independent comparisons it is exact. Second, there are two cures. A single test of all the means at once, the F test of ANOVA, holds its error at 5% by construction. Or keep the pairwise tests and tighten each one to 5% ÷ m, the Bonferroni correction. This lesson develops both.
One-way ANOVA asks one question: are all k population means equal? Its idea is to split the total variation in the data, SST, into the part explained by which group an observation belongs to, SSB, and what is left, SSW. That the pieces add up exactly, SST = SSB + SSW, is proved in the ANOVA derivation of Lesson 8. Dividing each by its degrees of freedom gives mean squares, and the ratio is the test statistic.
| Source | Sum of squares | df | Mean square | F | p-value |
|---|---|---|---|---|---|
| Between groups | 51,458 | 2 | 25,729 | 25.17 | < 0.0001 |
| Within groups | 21,466 | 21 | 1,022 | ||
| Total | 72,924 | 23 |
The group means differ by more than the scatter inside the groups would lead us to expect: F = 25.2 on (2, 21) degrees of freedom, so we reject the hypothesis that all three mean wages are equal. ANOVA does not say which group differs. It says at least one does. Widen the spread inside the groups to watch F fall without moving a single group mean.
| Source | Sum of squares | df | Mean square | F |
|---|---|---|---|---|
| Between sectors | 51,458 | 2 | 25,729 | 25.17 |
| Within sectors | 21,466 | 21 | 1,022 | |
| Total | 72,924 | 23 |
The wages of three sectors, eight workers each, give F = 25.17 on (2, 21) degrees of freedom. The 5% cut-off is 3.47, and p = 0.000003, so the hypothesis of equal mean wages is rejected. The share of the variation tied to sector is η² = SSB ÷ SST = 0.71, the same idea as R² in a regression: ANOVA is a regression of wages on sector dummies, and its F is the F of that regression.
Why divide the between variation by the within variation? Because the two mean squares are two different estimates of one number, σ², that agree when the means are equal and disagree when they are not. The within estimate is always right. The between estimate is right only when there is nothing to find.
MSW = SSW ÷ (N − k) adds up each group’s sum of squared deviations from its own mean and divides by the total degrees of freedom. It is the pooled variance of the two-sample lesson extended to k groups. Each group’s own variance sg² estimates σ² whether or not the group means differ, so MSW is an unbiased estimate of σ² in every case.
If every group has the same mean, the k sample means are k draws from the same distribution, each with variance σ² ÷ n. The sample variance of the k means therefore estimates σ² ÷ n, and n times it estimates σ². That is exactly MSB = n Σ(ȳg − ȳ)² ÷ (k − 1).
So when H₀ is true both mean squares estimate the same σ², and their ratio hovers near 1.
If the true means are μg, the sample means vary by sampling noise and by the real gaps, and the second source adds to MSB:
MSW is untouched. With three groups of 8, true means −10, 0 and 10 and σ = 10, E(MSB) = 100 + 8 × 200 ÷ 2 = 900, while E(MSW) is still 100. The ratio is about 9, far above 1. This is why a large F points to real differences between groups.
Under H₀, SSB ÷ σ² is a chi-square with k − 1 degrees of freedom and SSW ÷ σ² is an independent chi-square with N − k. A ratio of two independent chi-squares, each over its degrees of freedom, is an F (the F derivation), so
Drag the true means apart in the lab and watch MSB leave 100 behind while MSW stays put.
Let d = ȳ₁ − ȳ₂ and N = n₁ + n₂. The grand mean is (n₁ȳ₁ + n₂ȳ₂) ÷ N, so ȳ₁ − ȳ = n₂d ÷ N and ȳ₂ − ȳ = −n₁d ÷ N. Then
With k = 2 the between degrees of freedom are 1, so MSB = SSB. MSW is the pooled variance sp² on N − 2 degrees of freedom. And n₁n₂ ÷ N = 1 ÷ (1/n₁ + 1/n₂), so
Farm and Construction workers, eight in each. The pooled t statistic is −3.668, so t² = 13.451, and the ANOVA on the same sixteen wages gives F = 13.451 on (1, 14) degrees of freedom. The F table with 1 numerator degree of freedom is the t table squared, which is why a two-sided t test and the F test always agree.
A significant F says that at least one mean differs. It does not say which. To find out, compare the groups in pairs, but now with a correction, because you are back in the multiple-comparisons problem of Chapter 1. Use the within mean square from the ANOVA, not each pair’s own, since MSW pools all the information about σ². The standard error of the gap between groups g and h is √(MSW × (1/ng + 1/nh)), with N − k degrees of freedom.
The exact F distribution needs three things: the observations are independent, each group is roughly normal, and the groups share one variance. Of these, independence matters most and cannot be repaired afterwards. Moderate departures from normality hurt little, especially with equal group sizes. Unequal variances matter more when the group sizes differ.
Write the group means as coefficients on 0/1 group dummies and ANOVA’s F is the regression F of Lesson 12, with η² as R². With two groups the F is the square of the t statistic. These are one idea at three levels of generality.
This lesson has no past-paper set because none of the questions in our bank asks about ANOVA directly. The tests-in-practice lesson has its non-parametric alternative, and the Delhi School lesson has the false-alarm arithmetic for two tests run together. The exercise answers below were checked against the model file.
For the F table: the 5% point of F(2, 12) is 3.885.