Paste a table of counts or a list of category totals to test independence or goodness of fit. Returns chi-square, p, Cramér's V, a residual per cell and, for 2x2 tables, the odds ratio and Yates.
Chi-Square Calculator - Independence and Goodness of Fit
Paste a table of counts or a list of category totals to test independence or goodness of fit. Returns chi-square, p, Cramér's V, a residual per cell and, for 2x2 tables, the odds ratio and Yates.
Parameters
Enter data for calculations
💡 Fill in all required fields to unlock the calculate button
Chi-square test of independence and goodness of fit, straight from a pasted table
Of the 325 first-class passengers counted in the Titanic records that ship with R, 203 survived. Of the 706 in third class, 178 did. Paste those counts, together with second class and the crew, into this chi-square calculator and it returns chi-square = 190.401 on 3 degrees of freedom, a p-value of 5.00 × 10-41, Cramér's V of 0.294, and a residual for every cell showing where the table departs from independence. The same form runs a goodness-of-fit test on a single list of counts against equal shares or your own proportions, such as Mendel's 9:3:3:1. Row and column labels copied from a spreadsheet are kept and used in the result.
45 30 on the first line and 25 50 on the second, pick alpha 0.05. You get chi-square 10.714, p 0.0011, an odds ratio of 3.000 and, because the table is 2 × 2, the Yates-corrected value that R prints by default.
From a spreadsheet to a p-value in six steps
- Test - independence when you have a table that crosses two categorical variables (device by outcome, class by survival), goodness of fit when you have one list of counts and an expected split.
- Table of counts - one row per line. Copy cells straight from Excel or Google Sheets (tabs), or type them with spaces. A first row of column names and a first column of row names are optional; everything else must be a whole number.
- Observed counts - for goodness of fit, either the counts on one line (
18 22 16 25 19 20) or one category per line with its count (Red 50). - Expected distribution - equal shares, or your own proportions as percentages (
50 30 20) or a ratio (9:3:3:1). They are rescaled to your total, so they do not have to add up to 100. - Significance level - 0.05, 0.01 or 0.10. It sets the critical value shown next to the p-value.
- Read the result: chi-square and the verdict, the tiles, the observed and expected counts side by side, the residuals and the step table, which also carries the G-test and, for 2 × 2 tables, the odds ratio.
Seven data sets and what the test says about each
Example 1: Titanic survival by class
Situation: the R dataset Titanic summed over sex and age: 122 203 / 167 118 / 528 178 / 673 212 (died, survived) for first, second, third class and crew.
Result: chi-square 190.401, df 3, p 5.00 × 10-41, V 0.294. The biggest residual is first class, +12.59 survivors above independence; the crew sits at -6.87.
With 2,201 people almost any gap would be significant; the residuals and V say more than the p-value about how large the gap is.
Example 2: Party identification by gender
Situation: Agresti's textbook table from the General Social Survey, 762 327 468 women and 484 239 477 men across Democrat, Independent and Republican.
Result: chi-square 30.070, df 2, p 2.95 × 10-7, matching R's chisq.test. V is only 0.104, a weak association that is nonetheless very unlikely to be chance.
The Independent column barely moves (residual 0.70); the whole effect sits in the Democrat and Republican columns.
Example 3: Sign-ups on the web versus the app
Situation: 30 20 on the web and 19 31 in the app (signed up, left).
Result: chi-square 4.842, p 0.0278; with Yates' correction 4.002 and p 0.0455. Odds ratio 2.447, 95% interval 1.095 to 5.468.
Both versions stay under 0.05 here, but only just. When they fall on opposite sides the calculator says so.
Example 4: A pilot with nine people
Situation: 3 1 and 1 4.
Result: chi-square 2.723, p 0.0989, yet every expected count is below 5 (the smallest is 1.78). The Yates p is 0.3296, more than three times larger.
Counts this thin are a job for Fisher's exact test, which the result links to.
Example 5: Mendel's peas
Situation: 315 108 101 32 round-yellow, wrinkled-yellow, round-green and wrinkled-green, expected 9:3:3:1.
Result: chi-square 0.470, df 3, p 0.9254. The data fit the 9:3:3:1 ratio very closely.
Mendel's results fit so well overall that Fisher later argued they were too good to be true. A single p-value cannot settle that; it takes many experiments pooled together.
Example 6: Is the die fair?
Situation: 120 rolls: 18 22 16 25 19 20, equal shares.
Result: chi-square 2.500, df 5, p 0.7765, Cohen's w 0.144. No evidence of bias.
Twenty-five sixes against an expected 20 feels suspicious and is well inside ordinary chance.
Example 7: Which color do customers pick?
Situation: Red 50, Blue 30, Green 20, Yellow 20, one per line, equal shares.
Result: chi-square 20.000, df 3, p 0.0002. Red is flagged with a residual of 3.65; no other color crosses ±1.96.
Labels typed in front of the counts are carried into the table and the notes.
Three assumptions the p-value quietly depends on
Counts, not measurements. Every cell has to hold a number of people, items or events. Averages, percentages, ratings and sums of money break the arithmetic, because (O - E)² / E only follows a chi-square distribution when O is a count. If the question is whether two groups differ in a measured quantity, such as time on page or blood pressure, the right tool is a t-test or a rank test, not chi-square.
One observation, one cell. The test assumes independent observations. Two answers from the same respondent, a customer counted once per visit, or before-and-after readings on the same people all put the same person in the table twice. The expected counts then understate the real noise and the p-value comes out smaller than it should. Paired yes/no data (the same people before and after) needs McNemar's test, which looks only at the people who changed their answer.
Enough expected, not observed, per cell. The rule of thumb is about expected counts, the numbers in brackets in the result, not the ones you typed. A cell with an observed 0 is fine if the expected count is 12. A cell with an observed 9 is a problem if the expected count is 1.8. When the rule fails, merge neighboring categories that belong together (ages 60-69 and 70+, for example) or collect more data. For a 2 × 2 table there is an exact alternative, so there is no need to merge anything.
One more point that trips people up: a significant result says the variables are associated, not which way the influence runs, and not how strongly. The Titanic table does not prove that a first-class ticket saved lives by itself; class went together with where the cabins were and how far they were from the boat deck. Read the residuals for where, V for how much, and the design of the data for why.
Critical values of chi-square for 1 to 10 degrees of freedom
A statistic above the value in your row is significant at that alpha. Degrees of freedom are (rows - 1) × (columns - 1) for a table and categories - 1 for goodness of fit. The calculator shows the exact cutoff for your own df.
| df | alpha 0.10 | alpha 0.05 | alpha 0.01 |
|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 |
| 2 | 4.605 | 5.991 | 9.210 |
| 3 | 6.251 | 7.815 | 11.345 |
| 4 | 7.779 | 9.488 | 13.277 |
| 5 | 9.236 | 11.070 | 15.086 |
| 6 | 10.645 | 12.592 | 16.812 |
| 7 | 12.017 | 14.067 | 18.475 |
| 8 | 13.362 | 15.507 | 20.090 |
| 9 | 14.684 | 16.919 | 21.666 |
| 10 | 15.987 | 18.307 | 23.209 |
How big is the association? Cramér's V by table size
Cohen's rule of thumb uses w = 0.1, 0.3 and 0.5. For Cramér's V the same limits shrink as the smaller side of the table grows, because V divides by min(rows, columns) - 1. The calculator applies the row that fits your table.
| Smaller side of the table | Weak from | Moderate from | Strong from |
|---|---|---|---|
| 2 (any 2 × k table) | 0.10 | 0.30 | 0.50 |
| 3 | 0.07 | 0.21 | 0.35 |
| 4 | 0.06 | 0.17 | 0.29 |
| 5 | 0.05 | 0.15 | 0.25 |
What people ask before trusting a chi-square result
Related tools
Sample Size Calculator
Plan the number of responses for a survey or the people per group for a comparison before collecting counts - See calculator
Z-Test Calculator
Tests two proportions as an A/B test, with a one-sided option and the traffic needed for 80% power - See calculator
Fisher's Exact Test Calculator
The exact p-value for a 2 × 2 table when expected counts are small - See calculator
P-Value Calculator
Converts a chi-square, z, t or F statistic into a p-value and looks up critical values - See calculator
Pearson Correlation Calculator
Measures the linear link between two numeric variables, with a significance test - See calculator
Two-Sample T-Test Calculator
Compares the means of two groups when the outcome is a measurement rather than a count - See calculator