Home › Statistics & Probability Calculators › Chi-Square Test of Independence Calculator
Chi-Square Test of Independence Calculator
The chi-square test of independence asks whether two categorical variables are related, using a contingency table of counts: gender by preferred subject, treatment by outcome, region by vote. Type the table with one row per line and the counts separated by commas; tables of any size from 2 × 2 upward are accepted.
The calculator shows the row and column totals, the expected count for every cell (row total × column total ÷ N), each cell’s contribution (O − E)²/E, the χ² statistic with (rows − 1)(columns − 1) degrees of freedom, the p-value and the decision. For 2 × 2 tables Yates’ continuity correction is applied by default, matching R and SciPy; switch it off to match textbooks that omit it. Cramér’s V is reported as an effect size.
As with the goodness-of-fit test, expected counts below 5 make the approximation rough, and the tool flags them. For very small 2 × 2 tables, Fisher’s exact test is the alternative. For a single list of category counts against an expected pattern use the goodness-of-fit calculator.
At least 2 rows and 2 columns of counts.
Result and step-by-step solution
- State the hypothesesH₀: the row and column variables are independent. H₁: they are associated.
- Observed counts with totals
Col 1 Col 2 Col 3 Row total Row 1 30 10 20 60 Row 2 15 25 20 60 Column total 45 35 40 120 - Expected counts: E = (row total × column total) ÷ N
Col 1 Col 2 Col 3 Row 1 22.5 17.5 20 Row 2 22.5 17.5 20 - (O − E)² ÷ E for each cell
Col 1 Col 2 Col 3 Row 1 2.5 3.2143 0 Row 2 2.5 3.2143 0 - Sum the termsχ² = 11.4286, df = (rows − 1)(columns − 1) = (2 − 1)(3 − 1) = 2
- p-valueP(χ²2 ≥ 11.4286) = 0.0033
- Decisionp = 0.0033 < α = 0.05. Critical value = 5.9915.
| Cramér’s V (effect size) | 0.309 |
|---|
Frequently asked questions
- How do I enter the contingency table?
- One row per line, counts separated by commas or spaces. Enter only the counts, not the row or column totals; the calculator adds those.
- What is Yates' continuity correction?
- For 2 × 2 tables it subtracts 0.5 from each |O − E| before squaring, making the test more conservative. R and SciPy apply it by default; many introductory textbooks do not.
- How do I interpret a significant result?
- The two variables are associated: the distribution of one differs across the levels of the other. The test does not say which cells drive the association; compare observed and expected counts to see that.
- What is Cramér's V?
- An effect size from 0 (no association) to 1 (perfect association) computed from χ², N and the table size. Around 0.1 is small, 0.3 medium and 0.5 large for a 2 × 2 table.
Last reviewed: September 25, 2026. Calculations run in your browser and were validated against SciPy.
