Skip to main content
Examonaut

Topic 6 · Lesson 2 of 3

Contingency tables

Testing independence

A contingency table classifies each individual in two ways, such as age group and main news source. The question is whether the two classifications are independent.

  • H0H_0: the two variables are independent (no association).
  • H1H_1: they are not independent (there is an association).

If they are independent, the expected frequency in each cell is

E=row total×column totalgrand totalE = \frac{\text{row total} \times \text{column total}}{\text{grand total}}

For a table with rr rows and cc columns, the degrees of freedom are

ν=(r−1)(c−1)\nu = (r - 1)(c - 1)

because once the row and column totals are fixed, only (r−1)(c−1)(r - 1)(c - 1) cells can be filled freely.

Worked example

Sports clubs

120 students chose one of three clubs. Year 12: Football 30, Netball 10, Chess 20 (60 in all). Year 13: Football 20, Netball 20, Chess 20 (60). Column totals 50, 30, 40.

Show solution
  1. Expected for Year 12 and football: 60×50120=25\frac{60 \times 50}{120} = 25. The expected frequencies are 25,15,2025, 15, 20 in each row.
  2. X2=2(5225+5215+0)=2(1+1.667)=5.33X^2 = 2\left(\frac{5^2}{25} + \frac{5^2}{15} + 0\right) = 2(1 + 1.667) = 5.33.
  3. ν=(2−1)(3−1)=2\nu = (2 - 1)(3 - 1) = 2; at 10%, χ22(0.10)=4.605\chi^2_2(0.10) = 4.605.
  4. 5.33>4.6055.33 > 4.605: reject H0H_0. There is evidence of an association between year group and club chosen.

At 5%, with χ22(0.05)=5.991\chi^2_2(0.05) = 5.991, the same data would not be significant: always use the level the question gives.

Combining rows or columns

If some expected frequencies are below 5, combine a row (or column) with another one that makes sense in context, and recalculate the expected frequencies and degrees of freedom for the smaller table. A group of only 12 part-time students in a table of 150 might give expected frequencies of about 4, so it is combined with another group, and a 3×33 \times 3 table becomes 2×32 \times 3 with ν=2\nu = 2.

Interpreting a significant result

The test says only that there is an association. To describe it, look at the cells that contribute most to X2X^2 and compare OO with EE there: "more Year 12 students chose football than expected under independence (30 observed, 25 expected), and fewer chose netball (10 observed, 15 expected)". This is the kind of comment a final part asks for.

2 by 2 tables

For a 2×22 \times 2 table, ν=1\nu = 1, and every cell has the same ∣O−E∣|O - E|, because the row and column totals are fixed. (No continuity correction is used in this course.)

Practise this topic

Both are part of Premium.