A levels Further Mathematics · Further statistics
Chi-squared tests
1Observed and expected frequencies
A chi-squared ($\chi^2$) test compares observed frequencies $O$ with the expected frequencies $E$ predicted by a model.
The test statistic is
$$X^2 = \sum \frac{(O - E)^2}{E}$$
If the model fits well, $O$ and $E$ are close and $X^2$ is small. A large $X^2$ is evidence against the model.
Under $H_0$, $X^2$ approximately follows a $\chi^2$ distribution with $\nu$ degrees of freedom.
The 5% critical region is X² > 11.07 for 5 degrees of freedom. The die's value of 4.5 is well inside the acceptance region.
Check yourself
What does a large value of X² suggest?
Show the answer
The observed data does not fit the model well
Big gaps between O and E make X² large.
2Goodness of fit
Is the die fair?
- A die is rolled 120 times: 15, 25, 18, 22, 16, 24 for faces 1 to 6.
- $H_0$: the die is fair. Expected: 20 for each face.
- $X^2 = \frac{25 + 25 + 4 + 4 + 16 + 16}{20} = \frac{90}{20} = 4.5$.
- Degrees of freedom: $6 - 1 = 5$. Critical value at 5%: 11.070.
- $4.5 < 11.070$, so do not reject $H_0$: no evidence that the die is biased.
The test is always one-tailed (upper tail), because only large values of $X^2$ count against the model.
Check yourself
Why is a chi-squared test always one-tailed?
Show the answer
Only large values of X² show a poor fit
Small X² means good agreement.
3Degrees of freedom
The degrees of freedom are
$$\nu = \text{number of cells} - \text{number of constraints}$$
- The total always gives one constraint.
- Each parameter estimated from the data gives another.
Fitting a Poisson model
- Data on goals per match is grouped into 6 classes. The mean is estimated from the data to fit a Poisson distribution.
- $\nu = 6 - 1 - 1 = 4$.
Combining cells: each expected frequency should be at least 5. If not, merge neighbouring cells, then count the cells after merging.
Check yourself
Why must cells be combined when E < 5?
Show the answer
The chi-squared approximation is unreliable with small expected frequencies
Then recount the cells.
4Contingency tables
A contingency table tests whether two factors are independent.
Expected frequency for each cell:
$$E = \frac{\text{row total} \times \text{column total}}{\text{grand total}}$$
Degrees of freedom: $\nu = (r - 1)(c - 1)$ for $r$ rows and $c$ columns.
A 2 × 3 table
- Observed: group A: 30, 20, 10 (total 60); group B: 20, 30, 30 (total 80). Column totals 50, 50, 40; grand total 140.
- Expected for A: 21.43, 21.43, 17.14; for B: 28.57, 28.57, 22.86.
- $X^2 = 11.38$, with $\nu = (2 - 1)(3 - 1) = 2$. Critical value at 5%: 5.991.
- $11.38 > 5.991$: reject $H_0$. There is evidence of an association between group and choice.
Check yourself
What are the degrees of freedom for a 3 × 4 contingency table?
Show the answer
6
(3 − 1)(4 − 1).
5Interpreting and Yates' correction
After rejecting independence, look at which cells contribute most to $X^2$ to describe the association.
Interpreting
- In the 2 × 3 table, the largest contributions came from group A's first choice (more than expected) and group B's third choice (more than expected).
- So group A tends to prefer the first option, and group B the third.
For a 2 × 2 table ($\nu = 1$), some courses use Yates' continuity correction:
$$X^2 = \sum \frac{(|O - E| - 0.5)^2}{E}$$
It reduces $X^2$ slightly to correct for using a continuous distribution with discrete counts.
Check yourself
When is Yates' correction used?
Show the answer
For 2 × 2 contingency tables
The case with one degree of freedom.
6Hypotheses and conclusions
For a contingency table:
- $H_0$: the two factors are independent (no association);
- $H_1$: the factors are not independent (there is an association).
For goodness of fit:
- $H_0$: the model fits the data;
- $H_1$: the model does not fit the data.
Conclusions should be in context and non-definite: "there is evidence of an association between age group and preferred news source".
Association is not causation: a chi-squared test cannot show that one factor causes the other.
Check yourself
What is H₀ in a contingency table test?
Show the answer
The two factors are independent
No association.
Now test yourself
This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.
Practise in Impera