Lesson 5 of 6 · 14 min

Contingency tables and the chi-square test of independence

For categorical data, compare the count in each cell with the count you would expect if the two classifications had nothing to do with each other.

In short

  • A contingency table (two-way table) counts observations classified by two categorical variables.
  • H0 H_0 : the classifications are independent (not related); Ha H_a : they are not independent (related).
  • Expected frequency: Eij E_{ij} = (row i total × column j total) / overall total.
  • χ2=∑(Oij−Eij)2/Eij \chi^2 = \sum (O_{ij}-E_{ij})^2/E_{ij} over all m = r × c cells, with (r − 1)(c − 1) degrees of freedom.
  • The test is non-parametric and right-tailed: squared gaps make χ2≥0 \chi^2 \ge 0 , so only large values reject.

Unlock this lesson free for 7 days

Create a free account to get 7 days of full access — every lesson, video, flashcard, mock and the question bank. No card needed.

Contingency tables and the chi-square test of independence · Parametric and Non-Parametric Tests of Independence