Skip to main content
Daily Math Minute

Unit 8: Inference for Categorical Data: Chi-Square

Chi-Square Test for Independence

Testing for an association between two categorical variables.

Advanced25 min lesson3 min readUpdated August 12, 2026Author not yet attributed

Prerequisites

  • Chi-Square Goodness of Fit

Formally Testing the Association Seen Informally in Unit 2

Unit 2's two-way table showed 30% of juniors and 60% of seniors held part-time jobs — a difference that looked meaningful, but was only compared informally. Before reading on: could that same reasoning — comparing observed counts to what would be expected if the two variables were unrelated — be turned into a formal significance test?

Definition — Chi-Square Test for Independence

A chi-square test for independence uses one random sample, classified by two categorical variables, to test H₀: the two variables are independent, against Ha: they are associated. Expected count for each cell = (row total × column total)/grand total. The test statistic and df = (rows−1)(columns−1) follow the same structure as the goodness-of-fit test. A closely related design, the test for homogeneity, instead draws separate random samples from several populations and compares their distributions of one variable — the calculations are identical, but the study design and how the conclusion is phrased differ.

Worked Example — Testing the Grade Level and Job Status Table from Unit 2

H₀: grade level and job status are independent. Ha: they are associated. Expected counts: Junior/Yes = (100×90)/200 = 45; Junior/No = (100×110)/200 = 55; Senior/Yes = 45; Senior/No = 55 (all ≥ 5, condition satisfied). χ² = (30−45)²/45 + (70−55)²/55 + (60−45)²/45 + (40−55)²/55 = 5 + 4.09 + 5 + 4.09 = 18.18. df = (2−1)(2−1) = 1. The critical value for df=1, α=0.05 is 3.841.

Since χ² = 18.18 is far larger than 3.841, reject H₀: there is convincing evidence of an association between grade level and part-time job status. This confirms, formally, what the conditional distributions suggested informally in Unit 2 — juniors and seniors genuinely differ in how likely they are to hold a job, not just by chance sampling variation.

Tip

A chi-square test for independence can only conclude that an association exists — it says nothing about which direction, or by how much, since squaring the deviations discards that information. Interpreting the direction requires going back to the conditional distributions themselves.

Common Mistakes

  • Concluding a chi-square test for independence proves grade level causes different job-holding rates.

    This is observational data — no variable was randomly assigned — so, exactly as in Unit 3, only an association is established, never causation.

  • Confusing a test for independence (one sample, two variables) with a test for homogeneity (several samples, one variable).

    The arithmetic is identical either way, but the study design differs — one random sample classified by two variables calls for 'independence'; separate samples from distinct populations compared on one variable calls for 'homogeneity.'

Key Takeaways

  • A chi-square test for independence formalizes the same observed-vs-expected comparison a two-way table's conditional distributions suggest informally.
  • Expected counts use (row total × column total)/grand total, with df = (rows−1)(columns−1).
  • The test detects association, not its direction or size, and — like any test on observational data — never establishes causation.

Summary

This closes Unit 8: chi-square procedures test claims about entire categorical distributions and associations. The final unit returns to quantitative relationships, testing the regression slope from Unit 2 for statistical significance.

Chi-Square Test for Independence | Daily Math Minute