Chi-Square Test of Independence Calculator
Test whether two categorical variables are related, straight from the contingency table. Paste the observed counts; chi-square, degrees of freedom, the p-value, expected counts and effect size are calculated.
- Free · no sign-up
- The calculation runs in your browser; the values you enter are not sent to the server.
How is it calculated?
How is chi-square calculated?
The test of independence compares the observed counts with the counts expected if the two variables were unrelated. Each cell’s expected count is E = row total · column total / N. The test statistic is χ² = Σ (O − E)² / E, with (rows − 1) · (columns − 1) degrees of freedom.
Example: in a 2×2 table with cells 20, 30 and 30, 20, every expected count is 25; χ² = 4 · (5² / 25) = 4.00, with 1 degree of freedom and p = .046.
The expected count assumption
The chi-square distribution is an approximation and is unreliable when expected counts are small. The common rule goes back to Cochran (1954): if more than 20% of the cells have an expected count below 5, or any cell has one below 1, the result is not reliable. The calculator shows the table of expected counts, marks the cells below 5 and warns when the rule is broken.
In that case, rarely used categories in larger tables are merged where that makes theoretical sense; for a 2×2 table Fisher’s exact test is used.
2×2 tables: Yates’s correction and Fisher’s exact test
Yates’s continuity correction reduces chi-square in a 2×2 table by subtracting 0.5 from the difference between observed and expected; it is the “Continuity Correction” row in SPSS. Fisher’s exact test does not use the chi-square approximation: with the row and column totals fixed, it sums the probabilities of all tables as likely as or less likely than the observed one (two-tailed p). For a 2×2 table the calculator gives all three.
Effect size and reporting
Cramér’s V is given as the effect size: V = √(χ² / (N · k)), where k is one less than the smaller of the numbers of rows and columns. For a 2×2 table V equals the phi coefficient.
In APA format the degrees of freedom and sample size go in parentheses: χ²(1, N = 100) = 4.00, p = .046. Present the contingency table with counts and percentages; for a significant result, use the percentages to explain which cells drive the difference.
Frequently asked questions
- An expected count is below 5. What should I do?
- For a 2×2 table, report the p-value of Fisher’s exact test. For larger tables, consider merging sparse categories in a meaningful way or using an exact test; explain what you did in your method.
- Do I enter percentages or counts?
- Counts (observed frequencies). Chi-square cannot be calculated from percentages or means. Leave out the totals row and column.
- Should I use Yates’s correction?
- It applies only to 2×2 tables and is recommended for small samples; in large samples the difference is negligible. When expected counts are small, Fisher’s exact test is the more suitable option.
- Is this the chi-square goodness-of-fit test?
- No. This calculator runs the test of independence for two-variable contingency tables. The goodness-of-fit test, which compares one variable’s distribution with expected proportions, is a different calculation.
Other free calculators
- Sample Size Calculator
- Cronbach’s Alpha Calculator
- p-Value Calculator
- Effect Size Calculator
- Reference Generator from DOI
- Power Analysis Sample Size Calculator
- Lawshe Content Validity Ratio and Index Calculator
- AVE and Composite Reliability (CR) Calculator
- KR-20 Reliability Calculator
- Cohen’s Kappa and Percent Agreement Calculator
- Likert Scale Score Range Calculator
- Normality from Skewness and Kurtosis
- Independent-Samples t Test Calculator
- Confidence Interval Calculator