Chi-squared Test (AI SL)

The \(\chi^2\) test checks whether two categorical variables are associated (the test for independence, using a contingency table) or whether a set of observed frequencies matches a claimed distribution (the goodness-of-fit test). Both compare observed counts to the counts you'd expect if there were no association, then let the GDC turn that comparison into a \(p\)-value. It's part of the broader Hypothesis Testing topic.

32 questions on this sub-topic.

Practise the chi-squared test → Try exam-style questions

Degrees of freedom and expected frequency

Covered under IB syllabus reference SL4.11: the \(\chi^2\) test for independence with contingency tables and degrees of freedom, the \(\chi^2\) goodness-of-fit test, significance levels and \(p\)-values.

Degrees of freedom

\(\nu = (\text{rows}-1)(\text{columns}-1)\)

This is for the test for independence on a contingency table. A goodness-of-fit test instead uses \(\nu = (\text{number of categories}) - 1\).

Expected frequency

\(E = \dfrac{\text{row total} \times \text{column total}}{\text{grand total}}\)

Expected frequency \(>5\) in every cell - this is not in the formula booklet, it's a syllabus requirement for the \(\chi^2\) approximation to be valid.

Need the full syllabus wording, formula table, and GDC key sequences? See Hypothesis Testing.

Worked examples

1
Medium
GDC
[2 marks]

In a contingency table, a row total is 40, a column total is 30, and the grand total is 120.

Find the expected frequency for that cell.

Worked solution

Under independence, each cell's expected count is
\(E=\dfrac{\text{row total}\times\text{column total}}{\text{grand total}}=\dfrac{40\times 30}{120}=\dfrac{1200}{120}\) M1
\(=10.\) A1

M1 Recall E = (row×col)/total, substitute A1 E = 10
2
Hard
GDC
[6 marks]

200 cinema-goers are classified by age group (under 30 / 30-60 / over 60) and preferred film genre (action / comedy / drama). Observed frequencies:

ActionComedyDrama
Under 30403010
30-60253520
Over 60101515

(a) State \(H_0\) and \(H_1\).
(b) Find the degrees of freedom.
(c) Using the GDC, find the \(\chi^2\) statistic and \(p\)-value.
(d) State the conclusion at the 5% level.

Worked solution

(a) \(H_0\): age group and film genre are independent; \(H_1\): they are not independent. A1

(b) df. \((3-1)(3-1) = 4\). A1

(c) GDC. M1
Row totals 80, 80, 40; column totals 75, 80, 45; grand total 200. Expected: \(E_{11}=30,\ E_{12}=32,\ E_{13}=18,\ E_{21}=30,\ E_{22}=32,\ E_{23}=18,\ E_{31}=15,\ E_{32}=16,\ E_{33}=9.\) \(\chi^2 \approx 14.08,\quad p \approx 0.0288\). A1

(d) \(p \approx 0.0288 < 0.05\): reject \(H_0\). R1
There is significant evidence that age group and film preference are associated. A1

A1 Hypotheses A1 Df = 4 M1 GDC χ² test A1 Χ² and p-value R1 Comparison A1 Conclusion

Common mistakes

Ready to practise properly?

32 chi-squared questions, marked instantly like the real exam.

Quick answers

How do you find the degrees of freedom for a chi-squared test of independence?

For a contingency table, \(\nu = (\text{rows}-1)(\text{columns}-1)\). For a goodness-of-fit test it is instead the number of categories minus 1.

How do you calculate an expected frequency in a contingency table?

\(E = \dfrac{\text{row total} \times \text{column total}}{\text{grand total}}\), calculated for each cell under the assumption that the two variables are independent.

← Back to Applications & Interpretation SL topics