Cambridge International AS & A Level · Topic 4.3
A-Level Further Maths 9231 / Topic 4.3 / AS & A Level

Does the model fit the data?

A hypothesis says how the data ought to fall: equally, in a given ratio, or as a binomial, Poisson, geometric, normal or other distribution. Turn it into expected frequencies, measure the gap with \(\chi^{2} = \sum \dfrac{(O - E)^{2}}{E}\), count the degrees of freedom carefully and compare with the table.

The key idea

Under \(\text{H}_0\) (the model fits) find each expected frequency \(E = N \times P(\text{class})\). Combine neighbouring classes until every \(E \ge 5\). Then \(\chi^{2} = \displaystyle\sum \frac{(O - E)^{2}}{E} = \sum \frac{O^{2}}{E} - N\), with degrees of freedom \(\nu = k - 1 - m\), where \(k\) is the number of classes AFTER combining and \(m\) is the number of parameters estimated from the data. Reject \(\text{H}_0\) only when \(\chi^{2}\) exceeds the upper critical value: the test is always upper-tailed.

0 2 4 6 8 10 12 14 16 0.05 0.10 0.15 9.488 reject H₀: area 0.05 do not reject H₀: area 0.95 χ² with 4 degrees of freedom x f(x)
Fig. 1: the chi-squared distribution with 4 degrees of freedom. The shaded upper tail beyond 9.488 has area 0.05: a value of the test statistic there is significant at the 5% level
Section 01

Observed against expected.

A goodness of fit test starts with \(\text{H}_0\): the data come from a stated model, and \(\text{H}_1\): they do not. Under \(\text{H}_0\) each class has an expected frequency \(E = N \times p\). The statistic \(\displaystyle\sum \frac{(O - E)^{2}}{E}\) is 0 for a perfect match and grows as the observed frequencies \(O\) move away from \(E\). If \(\text{H}_0\) is true it approximately follows a \(\chi^{2}\) distribution, provided every \(E\) is at least 5.

Model in \(\text{H}_0\)Expected frequency of a class
uniform over \(k\) classes\(E = \dfrac{N}{k}\) in every class
given ratio \(a : b : c\)\(E = N \times \dfrac{a}{a + b + c}\), and so on
a distribution\(E = N \times P(\text{class})\) from that distribution

Degrees of freedom: with \(k\) classes the frequencies must add to \(N\), which uses up one, so \(\nu = k - 1\) when nothing is estimated from the data. Critical values come from the \(\chi^{2}\) table; at 5% they are 3.841, 5.991, 7.815, 9.488, 11.07 for \(\nu = 1\) to 5.

Worked example Is the dice fair?
A dice is thrown 120 times. The scores 1 to 6 occur 15, 25, 18, 22, 14 and 26 times. Test at the 5% level whether the dice is fair.
  1. \(\text{H}_0\): the dice is fair (each score has probability \(\frac{1}{6}\)). \(\text{H}_1\): the dice is not fair.
  2. Each \(E = \dfrac{120}{6} = 20\), all at least 5.
  3. \[\chi^{2} = \frac{25 + 25 + 4 + 4 + 36 + 36}{20} = \frac{130}{20} = 6.5\]
  4. \(\nu = 6 - 1 = 5\); the 5% critical value is 11.07.
  5. \(6.5 < 11.07\), so do not reject \(\text{H}_0\).
Answer: There is insufficient evidence at the 5% level that the dice is not fair
Worked example A given ratio, with the shortcut
Theory predicts that four types of seedling occur in the ratio \(9 : 3 : 3 : 1\). Of 160 seedlings, 98, 24, 27 and 11 are of the four types. Test at the 5% level whether the data are consistent with the theory.
  1. \(\text{H}_0\): the types occur in the ratio \(9 : 3 : 3 : 1\). \(\text{H}_1\): they do not.
  2. \(E = 160 \times \frac{9}{16}, \ldots\) gives 90, 30, 30, 10, all at least 5.
  3. \[\begin{aligned}\chi^{2} &= \sum \frac{O^{2}}{E} - N \\ &= \frac{98^{2}}{90} + \frac{24^{2}}{30} + \frac{27^{2}}{30} + \frac{11^{2}}{10} - 160 \\ &= 162.311 - 160 = 2.311\end{aligned}\]
  4. \(\nu = 4 - 1 = 3\); critical value 7.815. \(2.311 < 7.815\), so do not reject \(\text{H}_0\).
Answer: \(\chi^{2} = 2.31\): insufficient evidence at the 5% level that the ratio is not \(9 : 3 : 3 : 1\)
Your turn
A spinner with three equal sectors gives 30, 20 and 40 in 90 spins. Find \(\chi^{2}\) for the hypothesis that it is fair.
Examiner trap

Divide by \(E\), not by \(O\), and never add up \(O - E\) on its own: those differences always total 0. A small \(\chi^{2}\) does not PROVE the model; it only means the data give no evidence against it.

Section 02

Fitting a distribution, counting the freedom.

When \(\text{H}_0\) names a distribution, find the probability of each value, multiply by \(N\), and let the last class be 'or more' so the probabilities add to 1. If a parameter is not given, estimate it from the data (\(\lambda = \bar{x}\) for a Poisson, \(p = \dfrac{\bar{x}}{n}\) for a binomial). Each parameter estimated costs one more degree of freedom.

Worked example Poisson, mean estimated
The number of emails a help desk receives in 200 one-minute intervals is recorded: 0, 1, 2, 3, 4 and 5 emails occur 42, 72, 50, 22, 8 and 6 times (never more than 5). Test at the 5% level whether a Poisson distribution fits.
  1. \(\bar{x} = \dfrac{72 + 100 + 66 + 32 + 30}{200} = 1.5\), so use \(\text{Po}(1.5)\). \(\text{H}_0\): a Poisson distribution fits; \(\text{H}_1\): it does not.
  2. \(E = 200 \, P(X = x)\): 44.63, 66.94, 50.20, 25.10, 9.41 and, for \(x \ge 5\), 3.72.
  3. \(3.72 < 5\): combine '4' and '5 or more' into one class with \(O = 14\), \(E = 13.13\).
  4. \[\begin{aligned}\chi^{2} &= 0.155 + 0.383 + 0.001 \\ &\quad + 0.383 + 0.058 = 0.979\end{aligned}\]
  5. \(k = 5\) classes, \(\lambda\) estimated: \(\nu = 5 - 1 - 1 = 3\), critical value 7.815. \(0.979 < 7.815\): do not reject \(\text{H}_0\).
Answer: Insufficient evidence at the 5% level that the Poisson model does not fit; \(\text{Po}(1.5)\) is a reasonable model
Worked example Binomial, p estimated
Four seeds are planted in each of 100 pots and the number that germinate is counted: 0, 1, 2, 3, 4 germinate in 5, 14, 33, 32, 16 pots. Test at the 5% level whether \(\text{B}(4, p)\) is a suitable model.
  1. \(\bar{x} = \dfrac{14 + 66 + 96 + 64}{100} = 2.4\), so \(\hat{p} = \dfrac{2.4}{4} = 0.6\).
  2. \(E = 100 \binom{4}{x} 0.6^{x} 0.4^{4 - x}\): 2.56, 15.36, 34.56, 34.56, 12.96.
  3. Combine 0 and 1: \(O = 19\), \(E = 17.92\). Then \(\chi^{2} = 0.065 + 0.070 + 0.190 + 0.713 = 1.038\).
  4. \(\nu = 4 - 1 - 1 = 2\), critical value 5.991; \(1.038 < 5.991\): do not reject \(\text{H}_0\).
Answer: Insufficient evidence at the 5% level that \(\text{B}(4, 0.6)\) is unsuitable
Examiner trap

Count \(k\) AFTER combining and subtract one for every parameter you estimated. In the Poisson example the six values became five classes, and estimating \(\lambda\) took another degree of freedom away: \(\nu = 3\), not 5.

Stage 1 · Learn

Check your understanding

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

Two classes have observed frequencies 30 and 20 and expected frequencies 25 and 25. What is \(\chi^{2}\)?

Quick check+10 XP

A Poisson model, with \(\lambda\) estimated from the data mean, leaves 7 classes after combining. How many degrees of freedom?

Quick check+10 XP

The last class of a goodness of fit table has expected frequency 3.2. What should you do?

Quick check+10 XP

When is \(\text{H}_0\) rejected in a \(\chi^{2}\) goodness of fit test?

Section 03

Continuous models and reading the result.

For a continuous model the classes are intervals: \(E = N \times P(a \le X < b)\), found by integrating a given pdf or from normal tables. Once you have \(\chi^{2}\), look at the individual contributions \(\dfrac{(O - E)^{2}}{E}\). When one cell supplies most of a significant total, the model fails mainly in that class, and the conclusion can say so.

Worked example A given pdf, one cell stands out
A model for the time \(X\) hours to repair a machine has pdf \(f(x) = \dfrac{x}{8}\) for \(0 \le x \le 4\). For 80 repairs the times in \([0, 1), [1, 2), [2, 3), [3, 4]\) occur 12, 13, 22 and 33 times. Test at the 5% level whether the model fits, and comment.
  1. \(P(a \le X \le b) = \dfrac{b^{2} - a^{2}}{16}\), giving \(\frac{1}{16}, \frac{3}{16}, \frac{5}{16}, \frac{7}{16}\), so \(E = 5, 15, 25, 35\).
  2. \[\begin{aligned}\chi^{2} &= \frac{7^{2}}{5} + \frac{2^{2}}{15} + \frac{3^{2}}{25} + \frac{2^{2}}{35} \\ &= 9.8 + 0.267 + 0.36 + 0.114 = 10.54\end{aligned}\]
  3. \(\nu = 4 - 1 = 3\), critical value 7.815. \(10.54 > 7.815\): reject \(\text{H}_0\).
  4. The first class gives 9.8 of the 10.54: far more short repairs (12) than the model expects (5).
Answer: Sufficient evidence at the 5% level that the model does not fit, mainly because there are too many repairs under 1 hour
Worked example Normal with given parameters
It is claimed that heights of adult men in a town are \(\text{N}(170, 8^{2})\) in cm. For 200 men, the numbers below 162, from 162 to 170, from 170 to 178, and above 178 are 24, 70, 78, 28. Test the claim at the 5% level.
  1. The boundaries are \(z = -1, 0, 1\): probabilities 0.1587, 0.3413, 0.3413, 0.1587, so \(E = 31.73, 68.27, 68.27, 31.73\).
  2. \[\begin{aligned}\chi^{2} &= 1.884 + 0.044 + 1.387 + 0.439 \\ &= 3.753\end{aligned}\]
  3. \(\mu\) and \(\sigma\) were given, so \(\nu = 4 - 1 = 3\); critical value 7.815. \(3.753 < 7.815\): do not reject \(\text{H}_0\).
Answer: Insufficient evidence at the 5% level against the claim that heights are \(\text{N}(170, 8^{2})\)
Examiner trap

If \(\mu\) and \(\sigma\) had been estimated from the same 200 heights, \(\nu\) would be \(4 - 1 - 2 = 1\). And an extreme cell explains WHY a model fails; it does not let you drop that cell and test again.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to AS & A Level Further Mathematics Paper 1 to 4 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A random variable is modelled by \(\text{Po}(2.5)\). In 80 observations, find the expected frequency of the value 2.

Exam style+20 XP

Data are fitted by \(\text{B}(5, p)\), with \(p\) estimated from the data. The six classes 0 to 5 reduce to 4 after combining. Find the critical value for a test at the 5% level.

Exam style+20 XP

In a goodness of fit test with 3 degrees of freedom, \(\chi^{2} = 8.20\). Which conclusion is correct?

Exam style+20 XP

A geometric model \(\text{Geo}(0.5)\) is fitted to 64 observations with classes 1, 2, 3 and '4 or more'. Find the expected frequency of '4 or more'.

Skill unlocked

Model tested against the data.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
A fair-days test, degrees of freedom after combining, a genetic ratio, a geometric model, a Poisson with a given mean and a continuous pdf with a standout cell.