A-Level Further Maths 9231 / Topic 4.3 / AS & A Level
Are the two linked?
A contingency table counts people or objects by two features at once. If the features are independent, the totals alone predict every cell. The chi-squared test measures how far the real counts stray from those predictions, and the cells that stray most tell you what the association looks like.
H0: the two classifications are independent; H1: they are not independent (there is an association). Expected frequency \(E = \dfrac{\text{row total} \times \text{column total}}{\text{grand total}}\). Combine adjacent rows or columns until every \(E \ge 5\), then \(X^{2} = \sum \dfrac{(O - E)^{2}}{E}\) is compared with \(\chi^{2}_{\nu}\) where \(\nu = (r - 1)(c - 1)\) for the table you actually use. Reject H0 if \(X^{2}\) exceeds the critical value.
Fig. 1: 120 adults classified by age group and favourite exercise. If the two are independent, the expected number of under-30s who prefer the gym is 60 x 44 / 120 = 22; 30 were observed
Section 01
Independence or association?
In the goodness of fit lesson the expected frequencies came from a named distribution. In a contingency table they come from the table itself. If age group and favourite exercise are independent, then the proportion of all adults who prefer the gym, \(\frac{44}{120}\), should apply to the 60 under-30s as well, giving \(60 \times \frac{44}{120} = 22\). That is the rule \(E = \dfrac{\text{row total} \times \text{column total}}{\text{grand total}}\), used in every cell.
Observed
Gym
Running
Swimming
Total
Under 30
30
18
12
60
30 and over
14
22
24
60
Total
44
40
36
120
H0: age group and favourite exercise are independent (in the population of adults).
H1: age group and favourite exercise are not independent (there is an association).
Degrees of freedom: once the totals are fixed, only \((r - 1)(c - 1)\) cells are free; the rest are forced by subtraction. Here \(\nu = (2 - 1)(3 - 1) = 2\).
Worked example Every expected frequency
Find the expected frequencies for the exercise table above, assuming H0 is true.
Under 30, gym: \(\dfrac{60 \times 44}{120} = 22\). Under 30, running: \(\dfrac{60 \times 40}{120} = 20\). Under 30, swimming: \(\dfrac{60 \times 36}{120} = 18\).
The row totals are equal (60 and 60), so the 30 and over row has the same expected frequencies: 22, 20, 18.
Check: each expected row adds to 60 and each expected column adds to its observed total (44, 40, 36).
Answer: 22, 20, 18 in each row
Worked example One cell and the degrees of freedom
125 students are classified by distance from school (3 rows) and number of late arrivals in a term (4 columns: 0, 1-2, 3-5, 6 or more). The row total for 'over 5 km' is 35 and the column total for '6 or more' is 9. Find the expected frequency for that cell and the number of degrees of freedom for the full table.
\(\nu = (3 - 1)(4 - 1) = 2 \times 3 = 6\), if no rows or columns are combined.
But \(2.52 < 5\), so this table cannot be used as it stands: section 3 shows what to do.
Answer: \(E = 2.52\); \(\nu = 6\) for the uncombined table
Examiner trap
Do not round expected frequencies to whole numbers. They are averages, not counts: 2.52 and 14.4 are correct values. Rounding them changes every contribution and can change the conclusion.
Section 02
Contributions, then a decision.
Lay out \(\dfrac{(O - E)^{2}}{E}\) for every cell in a table of contributions. Their sum is the test statistic \(X^{2}\). Compare it with the critical value of \(\chi^{2}_{\nu}\) from the tables. Then look back at the biggest contributions: they show WHERE the association lies, and comparing \(O\) with \(E\) in those cells shows its direction.
\(\nu = (2 - 1)(3 - 1) = 2\). The 5% critical value of \(\chi^{2}_{2}\) is 5.991.
\(10.22 > 5.991\), so reject H0. There is sufficient evidence at the 5% level that age group and favourite exercise are associated.
The gym and swimming cells contribute most. More under-30s chose the gym than expected (30 against 22) and fewer chose swimming (12 against 18); the over-30s show the reverse. Running (0.200 per cell) plays almost no part.
Answer: \(X^{2} = 10.2 > 5.991\): evidence of association, driven by gym (younger) and swimming (older)
Worked example A 2 x 2 table, no Yates' correction
Of 40 students who revised with flashcards, 34 passed a test and 6 failed. Of 60 who did not, 38 passed and 22 failed. Test at the 5% level whether passing is independent of using flashcards.
H0: passing and using flashcards are independent. H1: they are not independent. Totals: pass 72, fail 28, grand total 100.
\(E\): flashcards \(\frac{40 \times 72}{100} = 28.8\) and \(11.2\); no flashcards \(43.2\) and \(16.8\). All are at least 5.
In a 2 x 2 table every \(|O - E|\) is the same, here \(5.2\), so \[ X^{2} = 5.2^{2} \left( \frac{1}{28.8} + \frac{1}{11.2} + \frac{1}{43.2} + \frac{1}{16.8} \right) = 5.589 \]
\(\nu = (2 - 1)(2 - 1) = 1\); the 5% critical value is 3.841. \(5.589 > 3.841\), so reject H0.
There is sufficient evidence at the 5% level of an association. The largest contribution (2.414) is flashcard users who failed: 6 observed against 11.2 expected, so flashcard users failed less often than independence predicts.
Answer: \(X^{2} = 5.59 > 3.841\): evidence that passing is associated with using flashcards
Your turn
In the flashcard test, would the conclusion change at the 1% level?
The 1% critical value of \(\chi^{2}_{1}\) is 6.635. \(5.589 < 6.635\), so at the 1% level H0 would not be rejected: there would be insufficient evidence of an association.
Examiner trap
Rejecting H0 shows an association, not a cause: the test cannot say that flashcards MADE students pass. Equally, not rejecting H0 never proves independence; write 'there is insufficient evidence of an association'.
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
In a contingency table with grand total 120, a cell has row total 40 and column total 30. If the classifications are independent, the expected frequency for the cell is
Quick check+10 XP
A contingency table has 3 rows and 4 columns and every expected frequency is at least 5. How many degrees of freedom does the test have?
Quick check+10 XP
A researcher records whether each of 200 people owns a pet and their age group. Which is the correct null hypothesis for a test of independence?
Quick check+10 XP
A 2 x 2 table has observed frequencies 20, 10 (first row) and 10, 20 (second row). Find \(X^{2}\).
Section 03
Combine until every E is at least 5.
The test statistic only follows a \(\chi^{2}\) distribution approximately, and the approximation is poor when expected frequencies are small. So before calculating \(X^{2}\), check every \(E\). If any is below 5, merge that row or column with a neighbouring one that makes sense (adjacent categories of an ordered scale), recompute the expected frequencies, and count the degrees of freedom from the NEW table.
Observed
0
1-2
3-5
6+
Total
Under 2 km
24
14
6
1
45
2-5 km
18
16
8
3
45
Over 5 km
8
10
12
5
35
Total
50
40
26
9
125
Worked example Combine, then test
The table shows the late arrivals of 125 students against distance from school. Test at the 5% level whether lateness is independent of distance.
H0: number of late arrivals and distance are independent. H1: they are not independent.
The '6+' expected frequencies are \(\frac{45 \times 9}{125} = 3.24\), 3.24 and 2.52, all below 5. Combine '6+' with the adjacent '3-5' column to make '3 or more' (totals 45, 45, 35; column total 35).
Combined observed: under 2 km 24, 14, 7; 2-5 km 18, 16, 11; over 5 km 8, 10, 17. Expected: 18, 14.4, 12.6 in the first two rows and 14, 11.2, 9.8 in the third. All at least 5.
\(\nu = (3 - 1)(3 - 1) = 4\), not 6. The 5% critical value of \(\chi^{2}_{4}\) is 9.488. \(12.87 > 9.488\), so reject H0: there is sufficient evidence at the 5% level that lateness is associated with distance.
Answer: \(X^{2} = 12.9 > 9.488\) with \(\nu = 4\): evidence of an association
Worked example Reading the contributions
Use the contributions in the previous example to describe the association.
The largest contribution, 5.290, is 'over 5 km, 3 or more': 17 observed against 9.8 expected.
Next come 'over 5 km, 0' (2.571: 8 against 14) and 'under 2 km, 3 or more' (2.489: 7 against 12.6).
The 2-5 km row contributes very little, so those students behave much as independence predicts.
Answer: Students living over 5 km away are late 3 or more times more often than expected, and those under 2 km less often
Examiner trap
Combine on EXPECTED frequencies, not observed ones: the '6+' column has observed 5 in one row, but its expected frequency 2.52 is what matters. And after combining, \(\nu\) comes from the new table: \((3 - 1)(3 - 1) = 4\), not the original 6.
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
In a test of independence on a 2 x 2 table, \(X^{2} = 3.2\). What is the conclusion at the 5% significance level?
Exam style+20 XP
A 3 x 4 contingency table is tested for independence at the 5% level. The expected frequencies in the last column are 3.1, 4.2 and 2.7, so the last two columns are combined. Which critical value should be used?
Exam style+20 XP
In a test of independence between diet (vegetarian or not) and sleep quality (good, fair, poor), H0 is rejected. The largest contribution is from 'vegetarian, good', where \(O = 30\) and \(E = 21\). Which comment is correct?
Exam style+20 XP
Why must expected frequencies be at least 5 before a chi-squared test of independence is carried out?
Skill unlocked
Association tested, and explained.
This skill is now recorded on your profile. Keep the chain going.