Goodness of fit and contingency tables

S3 Topic 4, spec point by spec point (Goodness of fit and contingency tables). Each spec point has the method, worked examples written the way the mark scheme wants them, how the marks go and the mistakes that cost the most marks.

Spec4.1Goodness of fit and contingency table tests

Null and alternative hypotheses, and the use of \(\sum\frac{(O_i - E_i)^2}{E_i}\) as an approximate \(\chi^2\) statistic. Applications include the discrete uniform, binomial, Normal, Poisson and continuous uniform distributions, and contingency tables.

The idea

Compare what you observed (\(O\)) with what a model predicts (\(E\)). If the model is right, the differences should be small. The statistic

\[X^2 = \sum\frac{(O - E)^2}{E} \quad \text{or equivalently} \quad X^2 = \sum\frac{O^2}{E} - N\]

is approximately \(\chi^2\). A large \(X^2\) means a poor fit, so the test is always upper-tailed.

Goodness of fit: method

  1. \(H_0\): the (named) distribution is a suitable model. \(H_1\): it is not.
  2. Find each expected frequency: \(E = N \times P(\text{cell})\) from the model. The \(E\) values must add up to \(N\) (use this to get the last cell).
  3. Combine cells with \(E < 5\) with neighbours.
  4. Calculate \(X^2\); find the degrees of freedom (4.2).
  5. Compare with the \(\chi^2\) critical value from the table; conclude in context.

Contingency tables: method

  1. \(H_0\): there is no association between the two factors (they're independent). \(H_1\): there is an association.
  2. Expected frequency for each cell:

\[E = \frac{\text{row total} \times \text{column total}}{\text{grand total}}\]

  1. Combine rows or columns if any \(E < 5\); then \(\nu = (r - 1)(c - 1)\).
  2. Calculate \(X^2\), compare, conclude in context. If significant, comment on which cells contribute most (where \(O\) is much bigger or smaller than \(E\)).

discrete uniform

200 random two-digit numbers fall in the ranges 00–19, 20–39, 40–59, 60–79, 80–99 with frequencies 53, 30, 45, 35, 37. Test at 10% whether they're uniformly distributed.

\(H_0\): uniform is a suitable model; \(H_1\): it isn't. Each \(E = 40\).

\(X^2 = \frac{13^2 + 10^2 + 5^2 + 5^2 + 3^2}{40} = \frac{328}{40} = 8.2\).

\(\nu = 5 - 1 = 4\); critical value \(\chi^2_4(10\%) = 7.779\). \(8.2 > 7.779\): reject \(H_0\).

There is evidence that the numbers are not uniformly distributed.

a 2 × 3 contingency table

Driving test results at three centres:

A B C Total
Pass 120 95 135 350
Fail 80 105 85 270
Total 200 200 220 620

Test at 5% for an association between centre and result.

\(H_0\): no association between centre and result. \(H_1\): there is an association.

Expected: Pass \(\frac{200 \times 350}{620} = 112.90\) (A and B), 124.19 (C). Fail 87.10 (A and B), 95.81 (C).

\(X^2 = 0.446 + 2.839 + 0.940 + 0.578 + 3.680 + 1.219 = 9.70\).

\(\nu = (2 - 1)(3 - 1) = 2\); critical value 5.991. Reject \(H_0\): there is evidence of an association between test centre and result. Centre B has more fails than expected.

  • Contingency: B1 hypotheses, M1 A1 expected frequencies, dM1 A1 for the \(\frac{(O - E)^2}{E}\) terms, M1 A1 for \(X^2\), B1 degrees of freedom, B1 critical value, A1 conclusion in context (WST03A Jan 2026 Q3a, 10 marks).
  • The last expected frequency can come from "the total must be \(N\)" (WST03 Jan 2025 Q2b).
  • Fitting a pdf: B1 hypotheses, M1 for \(E = 150 \times P(\text{interval})\), A1 all five, M1 A1 \(X^2\), B1 \(\nu\), B1ft critical value, A1 (WST03 Jun 2023 Q4b).

Often asked as: the most examined S3 topic by marks (71 questions). Usually a long question: expected frequencies (some given), pooling, \(X^2\), conclusion.

Rounding expected frequencies to whole numbers (they needn't be integers).

Hypotheses like "\(H_0\): the data are Poisson" without saying the model is "suitable", or reversing \(H_0\) and \(H_1\) for a contingency table.

Two-tailed thinking: the test only rejects for large \(X^2\).

Spec4.2Degrees of freedom

Degrees of freedom, including when one or more parameters are estimated from the data. Cells should be combined when \(E_i < 5\). Yates' correction is not required.

The rule

\[\nu = (\text{number of cells after combining}) - 1 - (\text{number of parameters estimated from the data})\]

The "\(-1\)" is because the expected frequencies are forced to add up to \(N\). Each parameter you estimate from the data (rather than being given) costs one more.

Model Parameters estimated from the data \(\nu\) (with \(k\) cells)
Discrete or continuous uniform none \(k - 1\)
Binomial, \(p\) given none \(k - 1\)
Binomial, \(p\) estimated 1 \(k - 2\)
Poisson, \(\lambda\) estimated 1 \(k - 2\)
Normal, \(\mu\) and \(\sigma\) estimated 2 \(k - 3\)
Contingency table (\(r \times c\) after combining) – \((r - 1)(c - 1)\)

Combine cells before counting \(k\). Fewer degrees of freedom means a smaller critical value.

Poisson with pooling

In 80 one-minute intervals, the numbers of calls 0, 1, 2, 3, 4, 5 had frequencies 10, 21, 23, 15, 7, 4. Test at 5% whether a Poisson model is suitable.

Mean \(= \frac{160}{80} = 2\), so use \(\text{Po}(2)\) (one parameter estimated).

Expected (\(80 \times P\)): 10.83, 21.65, 21.65, 14.44, 7.22, and "5 or more" 4.21.

\(4.21 < 5\), so combine "4" and "5 or more": \(O = 11\), \(E = 11.43\). Now 5 cells.

\(X^2 = 0.063 + 0.020 + 0.084 + 0.022 + 0.016 = 0.205\).

\(\nu = 5 - 1 - 1 = 3\); critical value 7.815. Not significant: the Poisson distribution is a suitable model.

  • B1 for \(\nu = 5 - 1 - 2 = 2\) when a Normal's mean and standard deviation are estimated, B1ft for the critical value, B1ft conclusion (WST03 Jan 2021 Q5).
  • Explaining degrees of freedom: B1 for identifying a cell with \(E < 5\), B1 for combining to give a \(3 \times 3\) table, so \((3 - 1)(3 - 1) = 4\) (WST03 Jan 2021 Q3d).
  • Effect of estimating parameters: more parameters estimated → fewer degrees of freedom → smaller critical value (WST03 Jan 2022 Q6c).

Often asked as: inside every goodness-of-fit question; short "explain the degrees of freedom" parts.

Counting cells before combining.

Forgetting to subtract for an estimated parameter (or subtracting when it was given).