All revision notes topics

Goodness of fit tests and contingency tablesEdexcel A-Level Further Maths: Revision notes

Section 1

Hypotheses and the test statistic

A goodness of fit test checks whether observed frequencies are consistent with a proposed model. State the hypotheses in words: H0\mathrm{H}_0: the model fits (for example, the die is fair, or the data follow B(4,p)\mathrm{B}(4,p)); H1\mathrm{H}_1: the model does not fit. The test statistic is X2=∑(Oi−Ei)2Ei,X^2=\sum\frac{(O_i-E_i)^2}{E_i}, where OiO_i are the observed frequencies and EiE_i the expected frequencies if H0\mathrm{H}_0 is true. X2X^2 is approximately χν2\chi^2_\nu distributed. A large value means the data are far from the model, so the test is always one-tailed (upper tail).

Key termsobserved frequencyexpected frequencytest statistic
Common mistake

Writing hypotheses about the sample ('the data are uniform'). They must be about the model or population.

Section 2

Expected frequencies and combining cells

Find each EiE_i as total ×\times probability. For a discrete uniform model with kk outcomes, Ei=nkE_i=\frac{n}{k}. For a binomial model, Ei=n P(X=i)E_i=n\,\mathrm{P}(X=i) using B(N,p)\mathrm{B}(N,p); for Poisson, Ei=n P(X=i)E_i=n\,\mathrm{P}(X=i) using Po(λ)\mathrm{Po}(\lambda), with the last cell as 'r or more' so the probabilities sum to 1. The χ2\chi^2 approximation is only reliable if every Ei≥5E_i\geq5. If a cell has Ei<5E_i<5, combine it with a neighbouring cell (adding both OO and EE) and count the combined cell as one. For example, expected frequencies 37.97,41.60,17.09,3.12,0.2137.97, 41.60, 17.09, 3.12, 0.21 become 37.97,41.60,20.4337.97, 41.60, 20.43.

Key termscombine cells
Common mistake

Combining the observed frequencies but leaving the expected frequencies uncombined (or the reverse).

Section 3

Degrees of freedom

The degrees of freedom are ν=(number of cells after combining)−1−(number of parameters estimated from the data)\nu=\text{(number of cells after combining)}-1-(\text{number of parameters estimated from the data}). The '−1-1' is because the total is fixed. If a parameter is given in the question (a fair die, p=12p=\frac12, λ=1.5\lambda=1.5) nothing more is subtracted. If it is estimated from the sample, subtract one for each estimate: p^=xˉN\hat p=\frac{\bar x}{N} for a binomial, λ^=xˉ\hat\lambda=\bar x for a Poisson. Examples: a die has ν=6−1=5\nu=6-1=5; B(4,p)\mathrm{B}(4,p) with pp estimated and 3 cells left has ν=3−1−1=1\nu=3-1-1=1.

Key termsdegrees of freedom
Exam tip

Always count the cells after combining, not before.

Section 4

Fitting uniform, binomial and Poisson models

Discrete uniform: H0\mathrm{H}_0: each outcome is equally likely; Ei=nkE_i=\frac nk; no parameters estimated, so ν=k−1\nu=k-1. Binomial B(N,p)\mathrm{B}(N,p): if pp is not given, estimate it from the sample mean, p^=xˉN\hat p=\frac{\bar x}{N}, then ν=cells−2\nu=\text{cells}-2. If pp is given, ν=cells−1\nu=\text{cells}-1. Poisson Po(λ)\mathrm{Po}(\lambda): if λ\lambda is not given, use λ^=xˉ\hat\lambda=\bar x; the final cell 'r or more' has E=n(1−∑i<rP(X=i))E=n\left(1-\sum_{i<r}\mathrm{P}(X=i)\right). When a last cell like '4 or more' is used, you need the total of the observations in that cell to find xˉ\bar x.

Key termsdiscrete uniformbinomialPoisson

Section 5

Contingency tables

A contingency table classifies each observation by two variables. The test asks whether they are independent: H0\mathrm{H}_0: there is no association between the variables (they are independent); H1\mathrm{H}_1: there is an association. Under H0\mathrm{H}_0, E=row total×column totalgrand total,E=\frac{\text{row total}\times\text{column total}}{\text{grand total}}, and ν=(r−1)(c−1)\nu=(r-1)(c-1) for rr rows and cc columns. No parameters are estimated separately (the formula for ν\nu already allows for the totals). Combine cells with E<5E<5 by merging rows or columns, and recalculate ν\nu from the new table. For a 2×22\times2 table ν=1\nu=1.

Key termscontingency tableindependence
Common mistake

Using ν=cells−1\nu=\text{cells}-1 for a contingency table. Use (r−1)(c−1)(r-1)(c-1).

Section 6

Reaching a conclusion

Compare X2X^2 with the critical value from the χν2\chi^2_\nu table at the given significance level (for example ν=5\nu=5 at 5% gives 11.07011.070; ν=2\nu=2 gives 5.9915.991; ν=1\nu=1 gives 3.8413.841). If X2≥X^2\geq critical value, reject H0\mathrm{H}_0. Alternatively, a calculator gives the p-value P(χν2≥X2)\mathrm{P}(\chi^2_\nu\geq X^2): reject H0\mathrm{H}_0 if it is below the significance level. Worked example: a die rolled 120 times gives E=20E=20 for each face, X2=9420=4.7X^2=\frac{94}{20}=4.7, ν=5\nu=5, critical value 11.07011.070. Since 4.7<11.0704.7<11.070, there is no evidence that the die is unfair. Always write the conclusion in context.

Key termscritical valuep-value
Exam tip

A small X2X^2 is not proof the model is right, only that there is no evidence against it.

That's the notes covered.

Carry on to the next subtopic.

Exam questions on Goodness of fit tests and contingency tables

  1. A six-sided die is rolled 120 times. The frequencies of the faces 1,2,3,4,5,61,2,3,4,5,6 are 14,25,17,22,24,1814, 25, 17, 22, 24, 18 respectively. A test is carried out, at the 5% significance level, of whether the die is fair.
    Calculate the value of the test statistic ∑(Oi−Ei)2Ei\sum\frac{(O_i-E_i)^2}{E_i}.2 marks
  2. A survey of 120 students recorded their gender and usual mode of travel to school. Of the 60 boys, 20 walk, 25 take the bus and 15 come by car. Of the 60 girls, 30 walk, 20 take the bus and 10 come by car. A χ2\chi^2 test is used to investigate whether mode of travel is associated with gender.
    The test statistic is 3.563.56, to 3 significant figures. State the conclusion of the test at the 5% significance level, giving the critical value used.2 marks
  3. A farmer packs eggs in boxes of 4. In a random sample of 100 boxes, the numbers of boxes containing 0,1,2,3,40,1,2,3,4 cracked eggs were 41,38,16,4,141, 38, 16, 4, 1 respectively. The farmer suggests that the number of cracked eggs in a box follows a binomial distribution B(4,p)\mathrm{B}(4,p), where pp is estimated from the data.
    Show that the estimate of pp is 0.2150.215, and find the expected frequency of boxes containing exactly one cracked egg, to 2 decimal places.3 marks
See the full worksheet

Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).