Chi-square test of independence (and homogeneity)
Tests whether two categorical variables are associated in an r × c contingency table by comparing observed counts with those expected under independence.
- Observed and expected counts in row i, column j.
- Row i total and column j total.
- Grand total.
- Numbers of rows and columns.
- Row and column proportions.
When to use
Two categorical variables measured on the same units (independence), or one categorical outcome compared across several groups (homogeneity) — the arithmetic is identical. For 2×2 tables with small expected counts use Fisher's exact test.
Assumptions
- Independent units, each in exactly one cell; counts, not percentages.
- Expected counts mostly ≥ 5 (the engine reports how many are below 5).
- Yates' continuity correction is optional (2×2 only) and off by default.
How to interpret
- A small p-value is evidence of association; it says nothing about direction or cause.
- Describe the association with conditional percentages (row or column percentages) and adjusted residuals.
- Effect size: Cramér's (0 = no association, 1 = perfect).
Common mistakes
- Using row percentages or means instead of counts.
- Counting the same person in several cells (e.g. multiple-response questions).
- Interpreting a significant result in a huge sample as a strong association — check V.
Example
Preferred plan (A, B, C) by region: North 20, 30, 25; South 30, 20, 25 (N = 150). All . on 2 df, , . Adjusted residuals are ±1.73 for plans A and B: no convincing evidence that preferences differ by region.