Chi-Square Tests
Overview
Chi-square tests address two fundamental questions about categorical data. The goodness of fit test determines whether a single categorical variable follows a specified distribution (e.g., is a die fair?). The test of independence determines whether two categorical variables are associated (e.g., is gender associated with voting preference?). Both use the same test statistic — the sum of squared differences between observed and expected frequencies, standardized by expected frequencies. When expected frequencies are small (), the chi-square approximation breaks down and Fisher's exact test should be used instead. Effect size is measured by Cramér's V.
Key Concepts
Degrees of Freedom
| Test | Formula | Example |
|---|---|---|
| Goodness of Fit (known ) | 6-sided die: | |
| Goodness of Fit (estimated params) | 10 bins, estimating μ and σ: | |
| Independence | table: |
Minimum Expected Frequency Rule
- No expected frequency should be less than 1
- No more than 20% of expected frequencies should be less than 5
- For tables violating this, use Fisher's exact test
Cramér's V Benchmarks
| Small | Medium | Large | |
|---|---|---|---|
| 1 | 0.10 | 0.30 | 0.50 |
| 2 | 0.07 | 0.21 | 0.35 |
| 3+ | 0.06 | 0.17 | 0.29 |
Quick Example
Key Takeaways
Deep Dive
For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:
Chi-Square Distribution
- Chi-Square Distribution — PDF, properties, relationship to Normal, critical values, and simulation
Goodness of Fit
- Chi-Square Goodness of Fit — Testing whether data matches a specified distribution with full worked examples
Test of Independence
- Chi-Square Test of Independence — Contingency tables, expected frequencies, post-hoc analysis, and standardized residuals
Related Tests
- F-Test for Equality of Variances — Comparing variances of two groups using the F-distribution
- Levene's Test — Robust alternative to F-test for equality of variances
Related Topics
- Hypothesis Testing — The framework underlying chi-square tests
- Nonparametric Methods — Distribution-free alternatives when assumptions are violated
- Logistic Regression — Models the same associations chi-square detects, with continuous predictors