Analysis of Variance

When three or more group means have to be compared — yields under four fertilisers, output of five machines — running t-tests on every pair inflates the chance of a false alarm. Analysis of variance (ANOVA) tests them all at once by splitting the total variation into a part between groups and a part within them, and comparing the two with an F ratio. This chapter covers one-way and two-way classified data, their ANOVA tables, degrees of freedom and assumptions.

The idea: split the variation

If the group means are really equal, the spread between group means should be about the size you would expect from the scatter within groups. If the means differ, the between-group spread is inflated. So ANOVA computes two estimates of the same variance and takes their ratio: F = (variance between groups) ÷ (variance within groups). A large F means the group means differ by more than chance explains.

  • Assumptions: observations are independent; each group is drawn from a normal population; all groups have the same variance (homoscedasticity).
  • H₀: all group means are equal; H₁: at least two differ.
  • The F test in ANOVA is always one-tailed in the upper tail.

One-way classified data

With k groups and N observations in all, grand total G: the correction factor is CF = G²/N; total SS = Σx² − CF; between-groups SS = Σ(Tᵢ²/nᵢ) − CF, where Tᵢ is the total of group i; within-groups (error) SS = total SS − between SS. Degrees of freedom: between k − 1, within N − k, total N − 1.

Worked data: three methods, three units each
MethodObservationsTotal TᵢMean
A5, 7, 6186
B8, 9, 10279
C4, 5, 6155
One-way ANOVA table
SourceSSd.f.MSF
Between methods2621313
Within (error)661—
Total328——

G = 60, N = 9, CF = 3600/9 = 400; Σx² = 432, so total SS = 32; between SS = (18² + 27² + 15²)/3 − 400 = 26; within SS = 6. F = 13/1 = 13 on (2, 6) d.f. The 5% table value of F(2, 6) is 5.14, so the three methods differ significantly.

⚠️ Exam trap
MS is SS divided by its own degrees of freedom; dividing the between SS by N − k (or the within SS by k − 1) is the commonest arithmetic slip and changes F completely.

Two-way classified data (one observation per cell)

When the data are classified by two factors — say r treatments (rows) and c blocks (columns), one observation in each cell — the total SS splits three ways: rows SS = ΣRᵢ²/c − CF, columns SS = ΣCⱼ²/r − CF, and error SS = total SS − rows SS − columns SS. Degrees of freedom: rows r − 1, columns c − 1, error (r − 1)(c − 1), total rc − 1. Each factor gets its own F against the error mean square.

The same nine values read as 3 methods × 3 blocks
SourceSSd.f.MSF
Methods (rows)2621339
Blocks (columns)4.6722.337
Error1.3340.33—
Total328——

Column totals are 17, 21 and 22, so columns SS = (289 + 441 + 484)/3 − 400 ≈ 4.67 and error SS ≈ 1.33. Taking the block effect out of the error made the error mean square smaller (0.33 against 1), which is exactly why a two-way layout is more sensitive than a one-way one when blocks really differ.

Exam traps and a quick revision

  • Total SS = between SS + within SS (one-way); = rows + columns + error (two-way).
  • One-way d.f.: k − 1, N − k, N − 1. Two-way: r − 1, c − 1, (r − 1)(c − 1), rc − 1.
  • CF = G²/N is subtracted in every SS formula.
  • F = MS(factor) ÷ MS(error); reject H₀ if F exceeds the table value.
  • ANOVA assumes independence, normality and equal variances.

Key takeaways

  • ANOVA tests the equality of several means at once with an F ratio.
  • CF = G²/N; total SS = Σx² − CF; between SS = ΣTᵢ²/nᵢ − CF.
  • One-way d.f.: between k − 1, within N − k.
  • Two-way with one observation per cell has error d.f. (r − 1)(c − 1).
  • Assumptions: independent observations, normal populations, equal variances.

Practice questions (10)

Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.

  1. Analysis of variance is used to test the hypothesis that:

    1. two population variances are equal
    2. several population means are equal
    3. two attributes are independent
    4. a population is normal
    Show answer

    Answer: B — several population means are equal

    Despite the name, ANOVA compares means: it uses the ratio of two variance estimates to decide whether three or more group means differ.
  2. In a one-way ANOVA with 4 groups and 20 observations in all, the degrees of freedom between and within groups are:

    1. 4 and 20
    2. 4 and 16
    3. 3 and 19
    4. 3 and 16
    Show answer

    Answer: D — 3 and 16

    Between = k − 1 = 3, within = N − k = 16, and they add to the total N − 1 = 19. Using k and N themselves forgets that each estimated mean uses up one degree of freedom.
  3. In a one-way ANOVA the total sum of squares is 50 and the between-groups sum of squares is 30. The within-groups sum of squares is:

    1. 20
    2. 80
    3. 1.67
    4. 15
    Show answer

    Answer: A — 20

    Total SS = between SS + within SS, so within SS = 50 − 30 = 20. Adding the two (80) or dividing them (1.67) treats the sums of squares as if they were not parts of one total.
  4. For 3 groups and 9 observations, the between-groups SS is 26 and the within-groups SS is 6. The F ratio is:

    1. 4.33
    2. 13
    3. 26
    4. 8.67
    Show answer

    Answer: B — 13

    MS between = 26/2 = 13 and MS within = 6/6 = 1, so F = 13. Dividing the sums of squares directly gives 26/6 ≈ 4.33, which ignores the degrees of freedom.
  5. In a two-way ANOVA with 4 rows and 5 columns and one observation per cell, the error degrees of freedom are:

    1. 19
    2. 7
    3. 12
    4. 20
    Show answer

    Answer: C — 12

    Error d.f. = (r − 1)(c − 1) = 3 × 4 = 12. Total d.f. = rc − 1 = 19 = 3 + 4 + 12.
  6. Which of the following is NOT an assumption of analysis of variance?

    1. the group means are equal
    2. populations are normally distributed
    3. population variances are equal
    4. observations are independent
    Show answer

    Answer: A — the group means are equal

    Equal means is the null hypothesis being tested, not an assumption. The assumptions are independence, normality and equal variances.
  7. Nine observations have a grand total of 60. The correction factor used in the ANOVA calculations is:

    1. 6.67
    2. 400
    3. 3600
    4. 60
    Show answer

    Answer: B — 400

    CF = G²/N = 3600/9 = 400. 3600 is G² before dividing, and 6.67 is the grand mean.
  8. In an ANOVA table the mean square between groups is 24 and the error mean square is 4. The F ratio is:

    1. 28
    2. 20
    3. 6
    4. 1/6
    Show answer

    Answer: C — 6

    F = MS between ÷ MS error = 24/4 = 6. The factor's mean square goes on top; inverting gives 1/6, and adding or subtracting mean squares has no meaning in ANOVA.
  9. In a one-way ANOVA the calculated F is 2.1 and the 5% table value is 3.5. The conclusion is:

    1. H₀ is not rejected: the group means do not differ significantly
    2. the test is invalid because F < 3.5
    3. the variances must be unequal
    4. H₀ is rejected: the group means differ
    Show answer

    Answer: A — H₀ is not rejected: the group means do not differ significantly

    Reject H₀ only when the calculated F exceeds the table value. 2.1 < 3.5, so the differences between group means are within what chance explains.
  10. In a two-way ANOVA with 3 rows and 4 columns (one observation per cell), total SS = 40, rows SS = 15 and columns SS = 12. The F ratio for rows is about:

    1. 1.15
    2. 2.17
    3. 7.5
    4. 3.46
    Show answer

    Answer: D — 3.46

    Error SS = 40 − 15 − 12 = 13 on (3 − 1)(4 − 1) = 6 d.f., so MSE ≈ 2.17. Rows MS = 15/2 = 7.5, and F = 7.5/2.17 ≈ 3.46.