Lesson 5 of 6 · All lessons in this module
  1. Parametric vs non-parametric tests, and correlation hypotheses
  2. The t-test for a Pearson correlation
  3. Sample size, p-values and many correlations at once
  4. The Spearman rank correlation testVideo lesson
  5. Contingency tables and the chi-square test of independenceVideo lesson
  6. Interpreting the result: standardized residuals and mosaics

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 free: every lesson, video and flashcard, and the question bank. No card needed.