MathsFurther Statistics 1 › Contingency tables

Contingency tables

Cross-tabulate two categorical variables and one chi-squared test asks whether they are independent. Expected counts come from the margins, and the degrees of freedom from the shape of the table.

Builds on Goodness-of-fit tests and Conditional probability.

IN THIS TOPIC

  • Compute expected frequencies as row total × column total ÷ grand total.
  • Use (rows − 1)(columns − 1) degrees of freedom.
  • State the hypotheses as independence and association, and conclude in context.

COMMON MISCONCEPTION

Expected frequencies in a contingency table come from assuming every cell is equally likely.

Expectations from the margins

The null hypothesis is that the two variables are independent. It is not that the cells are equal. Under independence the probability of a cell is the product of its row and column probabilities, so multiplying by the grand total gives:

Eij=row total×column totalgrand totalE_{ij} = \frac{\text{row total} × \text{column total}}{\text{grand total}}NOT IN THE BOOKLET — LEARN IT

The booklet prints the χ² statistic but not this, so learn how an expected frequency is built. Equal cells would be a far stronger claim, and nobody tests it here. A row holding twice as many observations should expect twice as much in every column, and that is exactly what the formula delivers. Independence is not uniformity.

Observed counts with their margins, and the expected counts independence demands: row total times column total over 1502030106030204090505050150observed202020303030expectedχ² = 16.67 on 2 degrees of freedom: an association
FIG. 1A 2 × 3 table with its margins: each expected count is the row total times the column total over 150, so the two rows expect the same split in different sizes.

WORKED EXAMPLE

Testing an association

A survey cross-tabulates two variables as rows (20, 30, 10) and (30, 20, 40). Test at the 5% level whether the variables are independent.

H₀: there is no association between the two variables. H₁: there is an association.

Row totals 60 and 90; column totals 50, 50, 50; grand total 150. Expected: 60 × 50/150 = 20 across the first row, and 30 across the second.

χ² = 0 + 5 + 5 + 0 + 3.33 + 3.33 = 16.67.

Degrees of freedom (2 − 1)(3 − 1) = 2, critical value 5.991.

16.67 > 5.991, so reject H₀. There is evidence at the 5% level of an association between the two variables.

Counting the freedom in a grid

Once the margins are fixed, filling in one cell of a 2 × 2 table forces every other. In general only (rows − 1)(columns − 1) cells are free, and that count is the degrees of freedom. Nothing is subtracted for estimated parameters here, because the margins have already absorbed them.

Individual contributions are worth a glance before you write the conclusion. In the example above the first column contributes nothing at all, while the four cells of the other two columns contribute between 3.33 and 5 apiece. The association therefore lives in how those two categories split between the rows. Naming the largest contributor and the direction it points earns the interpretation mark that a bare verdict misses.

Fixed margins on a 2 × 3 table: two free cells force the other four, so only two degrees of freedom remainfreefreeforcedfixedforcedforcedforcedfixedfixedfixedfixedrow and column totals are known(2 − 1)(3 − 1) = 2 degrees of freedom
FIG. 2Fixed margins on a 2 × 3 table: choosing two cells forces the other four, so the table carries just two degrees of freedom.

GUIDED PRACTICE

Degrees of freedom before and after pooling

A contingency table has 4 rows and 3 columns, with no expected frequency below 5. State the degrees of freedom. Then state them again for the case where two of the rows have to be combined.

Show the working

As it stands: (4 − 1)(3 − 1) = 6 degrees of freedom.

Combining two rows leaves 3 rows: (3 − 1)(3 − 1) = 4.

Pooling always costs degrees of freedom, since it removes cells that were free to vary.

ASSESSMENT FOCUS

  • Write the hypotheses as 'no association' against 'some association', naming both variables.
  • Compute expected frequencies to one decimal place and show at least one of them in full.
  • Degrees of freedom are (r − 1)(c − 1). Do not subtract again for estimated parameters.
  • If any expected frequency falls below 5, combine categories before computing the statistic.

CHECK YOURSELF

A contingency table has 3 rows and 4 columns. State the degrees of freedom, and find the expected frequency for a cell whose row total is 40 and column total is 30, with grand total 200.

Show a hint

(r − 1)(c − 1), and row × column ÷ total.

Show the answer

Degrees of freedom (3 − 1)(4 − 1) = 6. Expected frequency 40 × 30/200 = 6.

Expected = row total × column total ÷ grand total, which is independence written as arithmetic.

Degrees of freedom are (rows − 1)(columns − 1), because the margins have already used up the rest.

WORKBOOK

Printable practice for this topic: original exam-style questions with room to work, and a fully worked answer book. Free to use; please do not redistribute or sell.

7 questions on this topicAnswer them one at a time and mark yourself against the worked answer.Practise this topic

Or read them with their worked answers on the contingency tables questions page.

CHECK YOUR PROGRESS

Rate how confident you feel with each objective for this lesson. Ratings are saved in this browser, on this device, unless you sign in.

  • Compute expected frequencies as row total × column total ÷ grand total.
  • Use (rows − 1)(columns − 1) degrees of freedom.
  • State the hypotheses as independence and association, and conclude in context.

Open the full revision checklist to see every objective in the course in one place.