Chi-square reasoning for contingency tables

A contingency table organizes counts by two categorical classifications. Pearson’s chi-square method compares the counts actually recorded with the counts predicted if the classifications are independent. The size of those discrepancies, together with the table dimensions, guides a test of the null model.

From margins to expectations

For each cell, its expected count under independence equals its row total multiplied by its column total, divided by the grand total. This allocates each column among rows in the same proportions as the overall row totals. An expectation is a model prediction and need not match the observed count in that cell.


Pearson’s chi-square statistic sums (observed minus expected) squared, divided by expected, over every cell. A cell with a larger discrepancy contributes more, but the denominator also matters: the same absolute difference weighs more when its expectation is smaller. For an r-by-c table, the reference distribution has degrees of freedom equal to (r − 1)(c − 1).

Worked example

Consider a hypothetical 2-by-2 table with observed rows 12 and 33, then 8 and 47. Its row totals are 45 and 55, its column totals are 20 and 80, and its grand total is 100.


The expected counts are 9 and 36 in the first row, then 11 and 44 in the second: for example, the upper-left expectation is 45 × 20/100 = 9.


The four chi-square contributions are 9/9, 9/36, 9/11, and 9/44 because each observed count differs from expectation by 3.


Their sum is about 2.27, with (2 − 1)(2 − 1) = 1 degree of freedom. This arithmetic describes evidence against the independence model; interpreting its strength requires the appropriate reference distribution and sound sampling conditions.

Interpreting the test

A sufficiently large statistic relative to its chi-square reference distribution supports rejecting independence. In a homogeneity test, independently sampled groups can instead be compared for equal category distributions using the same table calculation. Neither use by itself establishes causation or identifies which particular cells account for a detected difference.



A 2-by-2 table has 60 observations in row 1, 40 in row 2, 30 in column 1, and 70 in column 2; grand total is 100. What is the expected count in row 1, column 1 under independence?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A study records four beverage categories across three independently sampled campuses. For a Pearson chi-square homogeneity test, what are the degrees of freedom?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A 2-by-3 table has expected counts 8, 12, 10 in each of its two rows. One observed cell count is zero. Which statement best evaluates the usual large-sample Pearson approximation?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors