Chi-square test calculator
Enter your table of observed counts, rows separated by semicolons or new lines. You get the chi-square statistic, degrees of freedom, p-value, the expected counts, Cramér's V and, for a 2×2 table, an optional Yates continuity correction.
Runs in your browser: nothing you enter is sent anywhere.
How to use it
- Type the observed counts. Separate rows with semicolons or new lines.
- For a 2×2 table you can switch on the Yates correction.
- Read χ², degrees of freedom and p. Check the expected counts.
How it works
χ² = Σ (O − E)² / E over all cells, where E is row total × column total / grand total. The p-value is the upper tail of the chi-square distribution, computed with the regularized incomplete gamma function. Cramér’s V = √(χ² / (n × min(rows − 1, columns − 1))).
Worked example
Table 10, 20; 30, 40 (n = 100):
- Expected: 12, 18; 28, 42
- χ² = 4/12 + 4/18 + 4/28 + 4/42 ≈ 0.794, df = 1
- p ≈ 0.373, so no evidence of association
- With Yates: 2.25 × (1/12 + 1/18 + 1/28 + 1/42) ≈ 0.446
Tips
- Use counts, not percentages.
- Each observation should fall in exactly one cell.
- A rule of thumb asks for expected counts of at least 5 in most cells.
Frequently asked questions
What does the chi-square test of independence check?
Whether two categorical variables are related. It compares your observed counts with the counts expected if the variables were independent.
How are expected counts calculated?
Expected = row total × column total / grand total. For the table 10, 20; 30, 40 the expected counts are 12, 18; 28, 42.
What are the degrees of freedom?
(rows − 1) × (columns − 1). A 2×2 table has 1 and a 3×4 table has 6.
When should I use the Yates correction?
It subtracts 0.5 from each absolute difference in a 2×2 table to make small-sample results less optimistic. Many analysts use Fisher's exact test instead when counts are small.
What does a small p-value mean?
If the variables were truly independent, a statistic this large would be unlikely. A common but arbitrary cut-off is 0.05. It does not measure the size of the effect, so use Cramér's V for that.