What the test checks
The chi-square test of independence asks whether two categorical variables are related. With a 2 × 2 table, it compares two groups on a yes/no outcome: did a new web page convert better, did a treatment group recover more often, do men and women answer a survey question differently?
The table
| Yes | No | |
|---|---|---|
| Group 1 | a | b |
| Group 2 | c | d |
The formulas
- χ² = N(ad − bc)² ÷ [(a + b)(c + d)(a + c)(b + d)], with N = a + b + c + d and 1 degree of freedom.
- With Yates’ correction: replace (ad − bc)² by (|ad − bc| − N/2)².
- p-value: for 1 degree of freedom, p = 2 × (1 − Φ(√χ²)), where Φ is the standard normal distribution.
- Phi coefficient φ = (ad − bc) ÷ √[(a + b)(c + d)(a + c)(b + d)].
Worked example
| Yes | No | Total | |
|---|---|---|---|
| Group 1 | 30 | 20 | 50 |
| Group 2 | 15 | 35 | 50 |
- ad − bc = 30 × 35 − 20 × 15 = 1,050 − 300 = 750.
- Denominator: 50 × 50 × 45 × 55 = 6,187,500.
- χ² = 100 × 750² ÷ 6,187,500 ≈ 9.09.
- p ≈ 0.0026: the difference between 60% and 30% yes is statistically significant at the 5% level.
- φ ≈ 0.30, a medium association.
- With Yates’ correction, χ² ≈ 7.92 and p ≈ 0.005.
Expected counts
The test compares observed counts with those expected if the variables were independent: expected count = row total × column total ÷ N. Here the smallest expected count is 45 × 50 ÷ 100 = 22.5.
The chi-square approximation is reliable only when every expected count is at least 5. Below that, use Fisher’s exact test.
Critical values for 1 degree of freedom
| Significance level | Critical χ² |
|---|---|
| 10% | 2.71 |
| 5% | 3.84 |
| 1% | 6.63 |
| 0.1% | 10.83 |
Interpreting carefully
- A significant result shows an association, not a cause.
- With very large samples, tiny and unimportant differences become significant: report the proportions and phi, not only p.
- The test needs independent observations: each person counted once. For paired data, such as before and after on the same people, use McNemar’s test.