Contingency tables and the chi-squared test
Studying this course? Keep your progress in one place.
Key facts
- : no association (independent). : there is an association. State both in context.
- Expected frequency .
- with ; reject if exceeds the upper-tail critical value.
- Every expected frequency must exceed : combine adjacent categories if not.
- The largest contributions show where the association lies.
Contingency tables and hypotheses
Whether two categorical variables are associated; always says they are independent.
A contingency table shows observed frequencies for two categorical variables, with rows and columns. The chi-squared test checks whether the variables are associated.
- : there is no association between the variables (they are independent).
- : there is an association.
Always state the hypotheses in the context of the question.
- no association (independent)
- there is an association
A survey records whether 100 students walk, cycle or take the bus to school, split by year group. What is the correct null hypothesis?
Expected frequencies
Multiply the row total by the column total and divide by the grand total.
If is true, the expected frequency in each cell is
Check that the expected frequencies have the same row and column totals as the observed table.
- Observed
- Expected
- Expected frequency
Worked example
150 employees: 40 walk to work and 70 live in town. Find the expected number who walk and live in town.
- 1
Row total (walk) is and column total (live in town) is .
- 2
Grand total is .
- 3
A table has row totals 30 and 70, column totals 40 and 60, and grand total 100. What is the expected frequency for the cell in row 1, column 2?
The test statistic and degrees of freedom
Compute and compare it with the upper-tail critical value for .
The test statistic is , approximately chi-squared when is true.
For an table the degrees of freedom are .
Large means the observed frequencies are far from those expected under . If exceeds the critical value, reject .
The test is one-tailed: a very small just means the data fit independence closely.
- Test statistic
- Degrees of freedom
| ν = 1 | ν = 2 | ν = 3 | ν = 4 | |
|---|---|---|---|---|
| Critical value at 5% | 3.841 | 5.991 | 7.815 | 9.488 |
| Critical value at 1% | 6.635 | 9.210 | 11.345 | 13.277 |
ν = 1
- Critical value at 5%:
- 3.841
- Critical value at 1%:
- 6.635
ν = 2
- Critical value at 5%:
- 5.991
- Critical value at 1%:
- 9.210
ν = 3
- Critical value at 5%:
- 7.815
- Critical value at 1%:
- 11.345
ν = 4
- Critical value at 5%:
- 9.488
- Critical value at 1%:
- 13.277
A contingency table has 3 rows and 4 columns. At the 5% level, what is the critical value?
Small expected frequencies
The approximation needs every expected frequency above ; otherwise combine adjacent categories and recalculate.
The chi-squared approximation is only reliable when all expected frequencies are greater than 5.
If any , combine categories: merge adjacent rows or columns so that every expected frequency exceeds . Then recalculate , and use the reduced degrees of freedom for the new table.
For example, expected frequencies of , and in a "not at all" column mean it should be combined with its neighbour.
- 1
Calculate every E
row total × column total ÷ grand total
- 2
Spot any E ≤ 5
the approximation is unreliable
- 3
Combine adjacent categories
merge neighbouring rows or columns
- 4
Recalculate
new E, new X² and new ν from the smaller table
A table has one column combined with its neighbour. What is the new number of degrees of freedom?
Sources of association
Look at each contribution : the largest ones show where observed and expected differ most.
If is rejected, find which cells cause it by looking at each contribution .
The cells with the largest contributions are the main sources of association. Compare with for those cells and describe the pattern in context, saying "more than expected" or "fewer than expected" and quoting and .
For example, at clinic Z, 20 dissatisfied patients were observed against expected, a contribution of .
- Contribution of a cell
- Largest contributionsmain sources of association
After rejecting , how do you decide which cells show the association?
Try an exam question
A contingency table classifies students by year group (3 groups) and by method of travel to school (4 methods). A chi-squared test of association is carried out at the 5% level. State the null hypothesis, the degrees of freedom, and the critical value.
[4 marks]
- [1]: year group and method of travel are independent (no association).
- [1].
- [1]Critical value at the 5% level is .
- [1]Reject if .
That's the notes covered.
Carry on to the next subtopic.
Try a question
Assuming no association, find the expected number of employees who drive and live in town.
1 mark, marked against the mark scheme
Assuming no association, find the expected number of employees who drive and live in town.
1 mark, marked against the mark scheme