ANOVA F-Test

Compare between-group and within-group variance to test whether group means differ.

Loading interactive simulation...

Lesson

The theory — ANOVA F-Test

A one-way ANOVA does not ask whether several group means differ — measured means always differ a little. It asks whether they differ more than random sampling alone would produce. The F-statistic makes that comparable by putting the spread between the group means over the spread within them, and the p-value says how often chance alone would manage a ratio that large.

What each symbol means

MS_between
the between-groups mean square: how far the group means sit from the overall mean, per degree of freedom.
MS_within
the within-groups mean square: the ordinary scatter of observations around their own group’s mean. This is the yardstick.
F
their ratio. Around 1 when the groups are alike, because then both are estimating the same thing.
p
the chance that groups which are genuinely identical would produce an F at least this large.

Where the formula comes from

  1. Suppose for the moment that every group has the same mean. Then the observations are all draws from one population, and there are two independent ways to estimate that population’s variance from the data you have.
  2. The first ignores the grouping entirely and just measures scatter inside each group: that is MS_within. It estimates the population variance whether or not the means differ, which is what makes it a fair yardstick.
  3. The second uses only the group means. If the groups really are identical, the means still wobble apart by sampling alone, and the size of that wobble is itself an estimate of the same population variance: that is MS_between. If the means are not identical, this second estimate is inflated by the real differences on top of the sampling wobble.
  4. So the ratio F = MS_between / MS_within compares an estimate that grows when the means differ against one that does not. Under “all means equal” it should land near 1 and follows a known distribution — the curve drawn above, fixed entirely by the two degrees of freedom. The p-value is the area of that curve to the right of your F.

How to read what you see

The blue curve is what F would do if every group mean were identical, and it depends on nothing but the two degrees-of-freedom numbers — not on your data. The red shaded tail is the rejection region: the values so far out that they would occur less than α of the time by chance, with the dashed line at the critical value marking where it begins. The green line is where your F actually landed. The whole test is the question of which side of the dashed line the green line falls on, and the p-value is the area to the right of it.

Assumes
Observations independent of each other, roughly normal within each group, and — the one that bites — roughly equal variances across groups. This page begins from the two mean squares rather than from your data, so it cannot check any of the three for you. It will compute a confident-looking p-value from any pair of positive numbers you type.
Breaks when
Equal variances is where it goes wrong quietly. MS_within pools the scatter of all the groups into a single yardstick, and if one group is far more variable than the others that yardstick describes none of them; the statistic no longer follows the curve above, and the p-value is measuring an area under the wrong distribution. The usual repair is Welch’s ANOVA, which does not pool. Unequal group sizes make the same problem worse, because the pooled estimate is then dominated by whichever group happens to be largest.

The number to beat is 1, not 0 🖖

F is a ratio of two variances, and that alone fixes its neutral value at 1 rather than 0. If the groups genuinely are alike, the spread between the group means and the spread within them are both estimating the same underlying population variance, so the ratio ought to land near 1 — set both mean squares to 3 and the readout is exactly 1. A value of 0 would require the group means to agree perfectly, which real samples never do. The ratio is also blind to units: 4 over 3 gives 1.3333, and so does 4000 over 3000. Multiply every measurement in the study by a thousand and F will not move.

The same F gets more convincing and less impressive at once 🖖

Hold F at 3.555 and change nothing but the within-groups degrees of freedom. At df₂ = 10 the p-value is 0.068195 and you would not reject; at 18 it is 0.049984, sitting exactly on the line; at 100 it is 0.032248. The ratio never moved — only the amount of data standing behind it. Now read the effect size across the same change: η² falls from 0.2832 to 0.0664. More data makes the same F harder to dismiss and, in the same breath, describes a smaller share of the variation. Significance is answering “could this be noise?” and effect size is answering “is it worth anything?”, and here they point in opposite directions.

The effect size is R² wearing a different name 🖖

η² is the share of the total variation that group membership accounts for — the between-groups sum of squares over the total. Now take the same data and run a regression that predicts every observation by its own group’s mean: its R² is that same number. The formula in the readout, η² = F·df₁ / (F·df₁ + df₂), is only that ratio rewritten using the quantities an ANOVA table happens to print. Analysis of variance and linear regression are not two techniques that give similar answers; they are one calculation with two vocabularies, and this row is where the two words touch.

Problem solved in full

  1. Three groups, thirty observations, and an F of 1.33 5 steps

    Three groups, thirty observations, and an F of 1.33 that is not significant. Work out where those degrees of freedom come from, and why you cannot simply run three t-tests instead.

    1. The F statistic is a ratio of two variance estimates: how much the group means differ, over how much the observations scatter within groups. A value near 1 says the groups differ about as much as chance alone would produce.

    2. The degrees of freedom tell you the design without being told. The first is groups minus one, so there are three groups; the second is total observations minus groups, so there are thirty observations.

    3. Multiplying each mean square by its degrees of freedom recovers the sums of squares — 8 between and 81 within, 89 in total.

    4. Their ratio is eta squared, the share of the total variation the grouping explains. Nine per cent.

    5. The alternative is to compare the three groups pairwise, which is three t-tests. Each carries a 5% false-positive rate, so the chance of at least one false alarm is 1 − 0.95³.

    Answer

    The tool prints F = 1.3333, degrees of freedom (2, 27) and η² = 0.0899. Two things follow. First, the effect size is not zero — the grouping does account for 9% of the variation — but with this much within-group scatter that is unremarkable, which is exactly what a non-significant F means and exactly what people forget when they read one as "no difference". Second, the reason ANOVA exists: three pairwise t-tests carry a 14.3% chance of at least one false positive against the 5% you thought you were buying, and with five groups that is ten tests and 40%. One test on all groups at once is the fix.

Learning path

When is a difference real?

Leads to Chi-square the same comparison for any number of groups, assembled from two variances instead of from one difference.

References (3)

Example problems

  • Weak Signal - MSB 4 against MSW 3 → F = 1.3333 on (2, 27): the number to beat is 1, not 0, so this is barely a signal
  • Strong Signal - MSB 18 against MSW 2 → F = 9 on (3, 40), with η² = 0.403
  • F and effect size disagree - MSB 5 against MSW 4 → F = 1.25, lower than the weak case, while η² rises to 0.122 — F and effect size can disagree
  • Exactly on the line - MSB 7.11 against MSW 2 → F = 3.555 on (2, 18), a hair above the 0.05 critical value of 3.5546, so p = 0.049984 and the decision flips if you nudge anything