Section 2.2

One-Way ANOVA

The t-test compares two groups. But what if you have three diets, four teaching methods, or five doses? Analysis of Variance (ANOVA) compares all the group means at once. The trick is beautiful: instead of comparing means directly, it compares variances.

Why not just run lots of t-tests?

With four groups there are six possible pairwise t-tests. Each carries a 5% false-positive risk, and those risks pile up: run enough and you're almost guaranteed a "significant" result by chance alone. ANOVA sidesteps this with a single omnibus test: one verdict on whether any of the groups differ.

The pile-up has a size, and it is worth working out once. With I groups there are I(I − 1)/2 pairs, so three groups give three tests and four groups give six. If the tests were independent and every null were true, the chance of at least one false alarm across k of them is 1 − (1 − α)k:

1 − (1 − .05)3 = .1426    1 − (1 − .05)6 = .2649

Six comparisons advertised at 5% deliver something closer to 26%. Pairwise tests on the same data are not really independent, so the true rate sits a little below those figures, but the size of the problem is right and it grows fast. The omnibus test buys one verdict at one α, and post-hoc tests pay a controlled price afterwards for the comparisons you actually want.

The F-ratio: signal vs. noise, again

ANOVA splits the total variation in the data into two pieces and takes their ratio:

F = (variance between groups) / (variance within groups)

If the groups really differ, their means are spread out (big between-group variance) relative to the scatter inside each group, so F is large. If the groups are all basically the same, the between-group variance is just noise of the same size as the within-group variance, and F sits near 1. The bookkeeping underneath (each MS as SS ÷ df, the two df, and η² from the same table) is laid out on the formula sheet.

🎮 The F-Ratio in Action

Four groups of the same people throughout: pull their means apart (more signal) or crank up the within-group scatter (more noise), and watch F and the p-value respond. The dashed line is the grand mean; “New samples” draws fresh people.

Between-group MS
Within-group MS
F-ratio
p-value
Verdict (α=.05)

Reading the result

The F-ratio comes with two degrees of freedom, one for each half of the ratio, and together they give the p-value. As usual, p < 0.05 means "this much separation would be surprising if all the groups were really identical." If you are still designing the study rather than reading one, the power calculator runs the same numbers backwards: tell it how many groups and how big an effect you care about, and it returns the n per group you need.

ANOVA is an omnibus test. A significant F says the group means are not all the same. It stays silent about which pair is responsible: group A might tower over the rest while B, C, and D are identical. To find out where the differences actually are, you follow up with post-hoc tests.

Explained and unexplained variation

Sixteen seedlings, and no two of them the same height. That variation came from somewhere, and the whole method of ANOVA is to sort it into two piles.

Ask two questions about any single seedling. How far is its group's mean from the mean of everybody? That distance is what the fertilizer dose might account for. And how far is the seedling itself from its own group's mean? Nothing in the design accounts for that, because two seedlings on the same dose were treated identically. The first pile is explained, or between-group, variation: the signal. The second is unexplained, or within-group, variation: the noise, and the technical name for one of those distances is a residual.

Each question is answered against a different mean, which is the detail most hand calculations get wrong. Between-group variation is measured from the grand mean, written x̄ with no subscript: the mean of all N observations pooled together, ignoring which group they came from. Within-group variation is measured from each observation's own group mean x̄i.

The three sums of squares

Distances either side of a mean cancel to zero by construction, so ANOVA squares them before adding, the same move the standard deviation makes for the same reason. A total of squared distances is a sum of squares, written SS, and each pile has one:

Sum of squaresFormulaRead it as
Between groups, SSGΣ ni(x̄i − x̄)²Each group mean's squared distance from the grand mean, weighted by the group's size.
Within groups, SSEΣ (x − x̄i)² = Σ (ni − 1)si²Every score's squared distance from its own group mean.
Total, SSTΣ (x − x̄)²Every score's squared distance from the grand mean.

Σ (sigma) is an instruction to add up whatever follows it. In SSG the sum runs over the I groups, and each squared distance is weighted by ni, that group's own size, because a mean built from twenty observations speaks for twenty of them. In SSE and SST the sum runs over all N observations.

The second form of SSE is the one to reach for when a question hands you summary statistics rather than raw scores: multiply each group's variance by its own degrees of freedom, ni − 1, and add. Every si here is a sample standard deviation on ni − 1, which is what SPSS prints and what a calculator's s key returns.

These are not three separate calculations. They satisfy an identity that holds for any data at all:

SST = SSG + SSE

which is the algebra of the sentence above. Every scrap of variation is either between the groups or inside them, and the two pieces add back to the whole. It is also the cheapest arithmetic check available: work out all three, and if they do not add up, one of them is wrong.

Degrees of freedom, mean squares, and F

A sum of squares grows with the number of things summed, so on its own it says nothing about size. Dividing by the count of independent pieces of information behind it fixes that, and that count is the degrees of freedom:

dfG = I − 1    dfE = NI    dfT = N − 1

with I the number of groups and N the total number of observations. Some books write k where this one writes I; the arithmetic is the same either way. The three add up exactly as the sums of squares do, since (I − 1) + (NI) = N − 1, and each comes from the same argument used everywhere else: I group means free to move around a grand mean they themselves fix leaves I − 1, and each group of ni scores around its own mean leaves ni − 1, which adds across groups to NI.

Divide a sum of squares by its degrees of freedom and you have a mean square, which is a variance:

MSG = SSG / dfG    MSE = SSE / dfE    F = MSG / MSE

and the ratio is read against F(I − 1, NI). There is no MST row worth printing, because SST/dfT is just the variance of the whole sample and no test uses it.

MSE is the more useful of the two once the omnibus test is over. It is the pooled estimate of within-group variance, the same pooled variance the two-sample t-test builds from two groups, generalized to I. Its square root is the pooled standard deviation,

sp = √MSE

and every follow-up comparison in the next section reuses it instead of recomputing a spread from the two groups in front of it. That is the practical argument for building the omnibus table even when you already know which pairs interest you: the table hands the follow-ups their error term.

One more number falls out of the same table, from two of its cells. The share of the total variation the grouping accounts for is

η² = SSG / SST

read eta squared, an effect size on the same 0-to-1 scale as R², and the reason effect sizes belong in the same sentence as the F. Because it is Greek it stays upright in APA style, and because it cannot exceed 1 it takes no leading zero.

🎮 Build the ANOVA Table

Four fertilizer doses, four seedlings each, height in centimeters after six weeks. Step through the build and the table fills in cell by cell, from the group means to the sums of squares to the F ratio. Type over any group's numbers to work with your own, or switch to exam mode, which blanks four cells and asks you to complete them from the rest.

Separate the values in a group with commas. Two to ten numbers per group.

 

F ratio
p-value
Pooled SD
Eta squared
Verdict (α = .05)

On the seedlings it boots with, the four doses are None, Low, Medium and High, and their means are 13, 17, 19 and 23 centimeters against a grand mean of 18, and the table comes out as SSG = 208 on 3 degrees of freedom, SSE = 48 on 12, SST = 256 on 15. That gives MSG = 69.33, MSE = 4.00, F(3, 12) = 17.33 and p = .0001, which an APA sentence reports as p < .001, with sp = 2.00 and η² = .813. Four seedlings a group is smaller than any study you would run; it is the size that fits on a page and on an exam paper, which is the job it is doing here.

Every score is its group mean plus a residual

Write one seedling's height out in full and the partition stops being an accounting trick:

x = x̄ + (x̄i − x̄) + (x − x̄i)

The three terms are the grand mean, the group's effect, and the residual. Fold the first two together and the sentence gets shorter: data = fit + residual. The fitted value for any observation is simply its own group mean, which is all this model has to offer, since it knows nothing about a seedling except which dose it received. Square each term, add over all N observations, and the cross-products vanish; what survives is SST = SSG + SSE.

That is the same decomposition regression uses, with a fitted line where this has a set of group means, which is why the two procedures print the same shape of output table. Categorical predictors and dummy coding makes the connection exact, by fitting the same group means as a regression on dummies.

Two groups, and F = t²

Nothing stops you running an ANOVA on two groups, and doing it once is worth the trouble. Load the builder with the untreated and high-dose seedlings alone, eight numbers and two groups, and the table returns F(1, 6) = 60.00 with p = .0002. Run the pooled two-sample t-test on those same eight numbers and it returns t(6) = 7.746, whose two-tailed p is the same number to every digit a calculator will show you. And 7.746² = 60.00.

The identity F = t² holds whenever dfG = 1, which is no coincidence: squaring a t on v degrees of freedom gives an F on (1, v), so the two tests are one test written twice. What the t version adds is a signed difference and a confidence interval for it, which is why it stays the one to report when there are two groups. ANOVA earns its keep from three groups upward.

What you're assuming

  • The groups are independent, and observations within each are independent.
  • The outcome is roughly normal within each group (or samples are large).
  • Homogeneity of variance, meaning the groups have similar spread. Checking that properly takes a plot and a test, and the next section covers what to run when the check fails.

When the spreads are not equal

The practice file at the foot of this lesson was built to break this assumption. study-methods.csv holds 35 students per revision method with standard deviations of 7.97, 8.86 and 11.97, and Levene's test duly objects: F(2, 102) = 3.54, p = .033. Run the ordinary ANOVA anyway and it returns F(2, 102) = 11.57, p < .001. Run Welch's ANOVA, which weights each group by its own precision rather than pooling everyone into one error term, and it returns F(2, 66.43) = 13.10, p < .001. Same story, with a fractional denominator df because the weighting has to be paid for somewhere.

The agreement is not luck, and the reason is the part the textbook warning usually omits. Unequal variances alone do surprisingly little damage; unequal variances paired with unequal group sizes do a great deal. Three groups drawn from populations that genuinely do not differ, 100,000 samples per row, testing at α = .05:

Group sizesPopulation SDsOrdinary F rejectsWelch rejects
20, 20, 201, 1, 37.4%5.2%
10, 20, 303, 2, 116.1%5.3%
10, 20, 301, 2, 32.1%4.9%

Read the middle row first. The smallest group is the noisiest one, and a test advertised at 5% false alarms delivers 16%. Flip the pairing so the big group carries the big spread and the rate drops to 2%. That direction looks like the safe one to err in, and it costs you too: a test that rejects too rarely under the null is missing real effects at the same time. The site's own dataset lands in none of these traps because its groups are the same size, and equal n is doing most of the protecting.

Welch holds near 5% in all three rows. What it costs when the variances really are equal is small and measurable: about one percentage point of power at 20 per group, about three at 10 per group. SPSS prints it under Robust Tests of Equality of Means, on a line above a second robust test called Brown–Forsythe. Be careful with that name, because two different procedures wear it. One is the robust F in that box; the other is the version of Levene's test that centers on medians instead of means, which is what R's car::leveneTest gives you by default. A significant omnibus still owes you follow-up comparisons, and those need the same correction the omnibus did: Games–Howell is Tukey's HSD rebuilt on the same principle.

Why it matters: ANOVA is the backbone of experimental statistics. Once you can partition variation into "between" and "within," you can extend the idea to multiple factors at once and to repeated measurements. The printable test-chooser poster lays that whole family out in one grid, from two groups up to two factors, and its companion assumption-checks sheet pairs each check with the fix it calls for.

For a run on real data, study-methods.csv compares three revision techniques across 105 students, with group SDs deliberately unequal so Levene's test has something to say.

Problem 13 of the practice problems builds a complete ANOVA table from fifteen raw scores, and Problem 14 carries the same data into the follow-up comparisons. Two more work the shapes an exam prefers: Problem 23 in the Stats 2 set rebuilds a whole table from three groups' means, SDs and n, and Problem 24 hands you a table with four cells missing.

Common questions

Why use ANOVA instead of running several t-tests?

With k groups, pairwise t-tests multiply: four groups means six tests, each carrying its own 5% false-positive risk — together far more than 5%. ANOVA asks one omnibus question ("are all the means equal?") at a single controlled α. If it's significant, you then localize the differences with corrected post-hoc comparisons.

What does a significant F-test tell you — and what doesn't it?

It tells you the group means are unlikely to all be equal: at least one differs from at least one other. It does not tell you which groups differ, how many differ, or by how much. For "which," run post-hoc tests; for "how much," report an effect size like η² alongside the F.

My ANOVA is significant but none of the post-hoc comparisons are. What happened?

Uncomfortable, but not a contradiction. The omnibus F gathers every group difference into one test, while each pairwise comparison examines one pair after paying a penalty for the whole family of comparisons. A pattern spread thinly across several groups can be enough for F and not enough for any single corrected pair. What a significant F does guarantee is that some contrast among the means is significant, and that contrast may combine groups rather than pit one against one. Report it as it is: the means differ overall, and the data are too thin to say which pair carries it. Post-hoc tests covers how the penalty works.