Chi-Square
calculator.
Compare the counts you observed with the counts a chi-square test would expect.
- p-value
- 2.95 × 10⁻⁷
- Critical at 0.05
- 5.991
- Cramér's V
- 0.104
The row and column categories look related. Female × Republican is furthest from expected, with 468 counted against 533.68. Cramér's V is 0.104, a small effect.
Your χ² on the curve
The shaded tail beyond χ² = 30.07 has area 2.95 × 10⁻⁷, which is the p-value. The critical value at α = 0.05 is 5.991. Your χ² lies past the right edge, so its tail is too small to see.
Working
- 1Expected count: row total times column total, over N1,557 × 1,2462,757= 703.67
- 2Take (O − E)² over E for each of the 6 cells(762 − 703.67)²703.67= 4.835
- 3Add them upχ² = 30.07
- 4Degrees of freedom: (rows − 1) times (columns − 1)(2 − 1) × (3 − 1) = 2
- 5The p-value is the area beyond χ²P(χ² ≥ 30.07) = 2.95 × 10⁻⁷
- 6Compare with the critical value at α = 0.0530.07 > 5.991, so reject H₀
- 7Check: expected counts add back to N, and the cells to χ²Expected total = 2,757, N = 2,757Cells add to 30.07
Observed and expected counts
| Cell | Observed | Expected | Adds to χ² | Residual |
|---|---|---|---|---|
| Female × DemocratObserved 762Expected 703.67 | 762 | 703.67 | 4.835 | 4.5 |
| Female × IndependentObserved 327Expected 319.65 | 327 | 319.65 | 0.169 | 0.7 |
| Female × RepublicanObserved 468Expected 533.68 | 468 | 533.68 | 8.084 | −5.32 |
| Male × DemocratObserved 484Expected 542.33 | 484 | 542.33 | 6.273 | −4.5 |
| Male × IndependentObserved 239Expected 246.35 | 239 | 246.35 | 0.22 | −0.7 |
| Male × RepublicanObserved 477Expected 411.32 | 477 | 411.32 | 10.489 | 5.32 |
Residual here is the adjusted residual. A residual beyond about ±2 marks a cell that adds a lot to a significant result.
χ² would be 30.07, with p = 2.95 × 10⁻⁷: significant at α = 0.05. Cramér's V stays at 0.104. At these proportions, χ² reaches the critical value at about N = 549.
Is the test a fair fit here?
- Expected counts under 5
- 0 of 6
- Expected counts under 1
- 0
- Rule of thumb
- Met
- Cramér's V band
- small
Rule: at least 80% of expected counts at 5 or more, and none under 1 (McHugh, 2013). Effect bands: 0.10 small, 0.30 medium, 0.50 large (Cohen, 1992).
How it's worked out
Both tests work on counts of categories, such as how many seeds were yellow. Goodness of fit uses one list of counts and asks whether they match a claimed split. A test of independence uses a two-way table and asks whether the rows and columns are related.
The statistic adds up how far each observed count O sits from its expected count E, scaled by E.
For goodness of fit, E is the total times the share you expect, and the degrees of freedom are the number of categories k minus 1. For a table with r rows and c columns, E comes from the totals.
A large is evidence against the claim being tested, so the p-value is the area in the right tail of the curve. An effect size then says how large the gap is, whatever the sample. That is Cohen's w for goodness of fit and Cramér's V for tables.
The tool also gives the G statistic, a likelihood ratio that tests the same hypothesis and usually agrees closely with . On a table with one degree of freedom it adds Yates' correction, which subtracts one half from each difference before squaring.
| df | α = 0.10 | α = 0.05 | α = 0.01 |
|---|---|---|---|
| 1 | 2.706 | 3.841 | 6.635 |
| 2 | 4.605 | 5.991 | 9.21 |
| 3 | 6.251 | 7.815 | 11.345 |
| 4 | 7.779 | 9.488 | 13.277 |
| 5 | 9.236 | 11.07 | 15.086 |
| 6 | 10.645 | 12.592 | 16.812 |
| 8 | 13.362 | 15.507 | 20.09 |
| 10 | 15.987 | 18.307 | 23.209 |
| 15 | 22.307 | 24.996 | 30.578 |
| 20 | 28.412 | 31.41 | 37.566 |
At the critical values are 10.828 for 1 df, 20.515 for 5 df, 29.588 for 10 df, 45.315 for 20 df. Reject the claim when is above the value for your row.
Worked examples
Theo tests a die
Theo rolls a die 60 times and counts 8, 9, 12, 11, 10, 10 of each face. With equal shares, every face is expected 10 times.
With 5 degrees of freedom, p = 0.9626, and the critical value at is 11.07. Theo has no evidence against the die. That is not proof it is fair: this same pattern of counts would need about 664 rolls to reach significance.
A class checks Mendel's peas
A genetics class takes Mendel's 556 seeds: 315 round yellow, 108 round green, 101 wrinkled yellow and 32 wrinkled green. Theory predicts 9:3:3:1, so the expected counts are 312.75, 104.25, 104.25, 34.75.
The contributions add to on 3 degrees of freedom, far under the critical value of 7.81, and p = 0.9254. The counts fit the ratio well. The ratio goes in as it is, because the tool scales it to the total.
Party and gender in a large survey
A General Social Survey table sorts 2,757 adults by gender and party. The first cell, women who are Democrats, has an expected count of 703.67, against the 762 counted.
All six cells give and G = 30.02 on 2 degrees of freedom, with p = 3 × 10⁻⁷. Party and gender are related. Yet Cramér's V is only 0.104, a small effect. The largest adjusted residual is 5.32, for Female × Republican.
A large sample makes a modest gap highly significant. With a tenth of the people in the same proportions, would be 3.01 and p = 0.2223.
Reading your result
Read p and the effect size together. The p-value says whether the gap is likely to be chance. The effect size says how big it is. Cohen's bands for w are 0.10 small, 0.30 medium and 0.50 large, and they apply to V once it is adjusted for the size of the table.
Check the expected counts first. The p-value comes from a large-sample approximation. One common rule asks for at least 80% of cells with an expected count of 5 or more, and none under 1. It is the expected count that matters, not the count you observed.
Use residuals to see where the gap is. A significant test does not say which cell differs. A residual beyond about 2 either way marks a cell worth a look. In a 2 by 2 table of 647, 622, 2 and 27, the adjusted residual is 4.7 in size in all four cells, since such a table has one degree of freedom.
A small p is not a proven cause. The test finds a link between categories. It cannot tell you why it is there, or which way it runs.
Common mistakes
- Entering percentages. The cells must hold counts. Turn percentages back into counts with the total first, because 50% of 20 and 50% of 2,000 carry very different evidence.
- Counting a person twice. Each person or item must fall in one cell only. Before and after answers from the same people need a test for paired data, such as McNemar's test.
- Running it on sparse counts. Counts of 3, 1 and 2 have expected counts of 2 each, so 3 of 3 cells break the rule. Merge categories, or use Fisher's exact test on a 2 by 2 table.
- Reading a large p as proof of a fit. A high p-value means the data give no evidence against the claim. With a small sample, that says little.
Questions people ask
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.15, Chi-Square Goodness-of-Fit Test
- NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.6.7.4, Critical Values of the Chi-Square Distribution
- OpenStax, Introductory Statistics 2e, section 11.2, Goodness-of-Fit Test
- McHugh, M. L. (2013), The Chi-square test of independence, Biochemia Medica 23(2), 143-149
- Cohen, J. (1992), A power primer, Psychological Bulletin 112(1), 155-159
- R documentation, chisq.test
- R documentation, mcnemar.test