CHAPTER 05 · TOPIC 04
Chi-Square Test of Independence
Derive expected counts from marginal totals and test association between two categorical variables.
On this page
The chi-square independence test evaluates whether two categorical variables observed in a population are independent using the entire contingency table. The difference between the observed frequencies and the expected frequencies if they were independent is summarized in the Pearson chi-square statistic.
Hypotheses#
Deriving expected count from independence#
Expected Counts in a 2×2 Table#
| cell | observed count | Expected count under independence |
| A | A | (A+B)(A+C)/N |
| B | B | (A+B)(B+D)/N |
| C | C | (C+D)(A+C)/N |
| D | D | (C+D)(B+D)/N |
Pearson chi-square statistic#
Standardize the difference in each cell by the expected count, then square it and add it to remove the sign. The larger χ² is, the harder the table is to explain using an independent model. Also check the residuals to see which cells contributed to the difference.
Degrees of Freedom#
Simplified formula for 2×2 table#
In a 2×2 table, only one cell is free once the marginal totals are determined. If you divide the deviation of A, the following common term will appear, and if you put the Pearson terms of the four cells together, you will get a simplified formula.
The p-Value Comes from the Right Tail#
Since χ² is non-negative and increases in value as the deviation from H₀ increases, only the right tail is used regardless of direction. However, even if it becomes significant, we do not know the direction or strength of the association, so we also report the cell percentage, residual, OR, and RR.
Selection of approximation conditions and method#
- Each observation enters only one cell, and the observation unit is independent.
- Make sure that the expected count is not extremely small. Standards are not fixed absolute laws.
- Consider Fisher exact test for small sample 2×2 tables
- If you want to make the approximation conservative in a 2×2 table, Yates correction is also an option, but it can be too conservative.
- Use McNemar test instead of independence test for paired binary data