Chi-Square Test Calculator
Type your counts into the table, or paste one from a spreadsheet…
Type your counts into the table, or paste one from a spreadsheet, to test whether the rows and columns are related, with each cell’s expected count beside it.
exp 43.5 | exp 26.6 | exp 21.9 | |
exp 47.2 | exp 29 | exp 23.8 | |
exp 46.3 | exp 28.4 | exp 23.3 |
Paste a table from a spreadsheet
Copy cells from Excel, Google Sheets or a CSV file and paste them here; the grid above follows.
ExampleP-value
4.81 × 10⁻⁸
The rows and columns look related. The biggest gap is 50 and over, Print or TV: 41 counted where 23.3 were expected. Significant at the 5% level (p < 0.05).
Type your own counts, or paste a table.
Each column is as wide as its total and split by the rows. Tiles above or below a dashed line hold more or fewer than independence predicts.
The chi-square distribution with 4 df, what χ² looks like when nothing is going on; the shaded tail beyond yours is the p-value.
- χ², df
- 39.7784, 4
- Cramér’s V
- 0.262
- Expected counts under 5
- None
How this works: 9 sources,
How this works
Method
The chi-square test of independence asks whether two ways of sorting the same people are related: age group and where people read the news, treatment and outcome, region and preferred product. The table of counts goes in; the question is whether the rows split the same way in every column. In the example, 67% of 18 to 29 year olds read news mostly on a phone against 28% of those over 50. Full method
Sources
- Wikipedia, Pearson’s chi-squared test
- Cochran, Some methods for strengthening the common χ² tests (Biometrics, 1954)
- NIST/SEMATECH e-Handbook of Statistical Methods
- Abramowitz and Stegun, Handbook of Mathematical Functions, chapters 6, 7 and 26 (1964)
- SciPy 1.18 scipy.stats (reference values for the tests)
- statsmodels 0.15 (reference values for the A/B test and regression intervals)
- Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika) (1947)
- Fleiss, Levin and Paik, Statistical Methods for Rates and Proportions, 3rd edition (sample size for two proportions) (2003)
- Hyndman and Fan, Sample quantiles in statistical packages (The American Statistician) (1996)
How it’s tested
2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.
How the chi-square test of independence works
The chi-square test of independence asks whether two ways of sorting the same people are related: age group and where people read the news, treatment and outcome, region and preferred product. The table of counts goes in; the question is whether the rows split the same way in every column. In the example, 67% of 18 to 29 year olds read news mostly on a phone against 28% of those over 50.
If the two were unrelated, each cell would hold its row total times its column total divided by the grand total: the expected count shown under every cell. The statistic adds up (observed − expected)² ÷ expected over all cells and is compared with a chi-square distribution with (rows − 1) × (columns − 1) degrees of freedom. Here χ² is about 40 on 4 df, far beyond the 9.49 a 5% test needs.
The approximation needs enough data in each cell. The usual rule, from Cochran, is that no more than 20% of the expected counts should be under 5 and none under 1; the grid flags small ones. For a 2 × 2 table with small counts, Fisher’s exact test is the better choice. Cramér’s V gives the strength of the association on a 0 to 1 scale, since χ² grows with the sample size.
Eᵢⱼ = Rᵢ × Cⱼ ÷ N · χ² = Σ (Oᵢⱼ − Eᵢⱼ)² ÷ Eᵢⱼ, df = (r − 1)(c − 1)
- Pearson’s chi-squared test, introduced in 1900, compares observed and expected frequencies; for a contingency table the expected counts come from the row and column totals. Source: Wikipedia, Pearson’s chi-squared test.
- Cochran recommended that no more than 20% of the expected counts be less than 5 and none less than 1 for the chi-square approximation to be adequate. Source: Cochran, Some methods for strengthening the common χ² tests (Biometrics, 1954).
Critical χ² values by table size
The chi-square statistic a test of independence must exceed for p < 0.05 and p < 0.01, by the shape of the table.
| Table | df | χ² (5%) | χ² (1%) |
|---|---|---|---|
| 2 × 2 | 1 | 3.841 | 6.635 |
| 2 × 3 | 2 | 5.991 | 9.21 |
| 2 × 4 | 3 | 7.815 | 11.345 |
| 3 × 3 | 4 | 9.488 | 13.277 |
| 2 × 5 | 4 | 9.488 | 13.277 |
| 3 × 4 | 6 | 12.592 | 16.812 |
| 4 × 4 | 9 | 16.919 | 21.666 |
| 3 × 5 | 8 | 15.507 | 20.09 |
| 4 × 5 | 12 | 21.026 | 26.217 |
| 5 × 5 | 16 | 26.296 | 32 |
Show all 12 rowsShow fewer
| 5 × 6 | 20 | 31.41 | 37.566 |
| 6 × 6 | 25 | 37.652 | 44.314 |
Common questions
Can I use percentages instead of counts?
No. The test needs the actual counts: 60% of 10 people and 60% of 1,000 people say very different things. Convert percentages back to counts with the number of people in each group.
Should I use Yates’ continuity correction?
For a 2 × 2 table, R’s chisq.test and SciPy apply it by default and it makes the test more cautious. Many statisticians now prefer no correction, or Fisher’s exact test when counts are small. This page shows both and lets you choose under More options.
The test is significant. Which cells cause it?
Look at the mosaic plot: tiles far above or below their dashed line, shaded darkest, are the cells furthest from independence. The worked example also lists each cell’s share of χ².