Chi-Square Test Calculator
Perform chi-square goodness-of-fit tests or tests of independence. Calculate the chi-square statistic, p-value, degrees of freedom, and Cramér's V for effect size. See also our Chi-Square Distribution Calculator, ANOVA Calculator, and P-Value Calculator.
How to Use the Chi-Square Test Calculator
The chi-square test is a non-parametric test for categorical data. The goodness-of-fit test determines whether observed frequencies match expected frequencies from a theoretical distribution. The test of independence determines whether two categorical variables are associated in a contingency table.
For goodness of fit, enter observed and expected frequencies for each category. For the test of independence, specify the number of rows and columns in your contingency table, then enter the observed counts. The calculator computes the chi-square statistic, degrees of freedom, p-value, and (for independence tests) Cramér's V as a measure of effect size.
Requirements: (1) data must be frequencies (counts), not percentages, (2) expected frequencies should be at least 5 in each cell (some texts allow 80% of cells ≥ 5), (3) observations must be independent. If expected counts are too small, consider combining categories or using Fisher's exact test.
Formula
Chi-Square Statistic:
χ² = Σ (Oᵢ - Eᵢ)² / Eᵢ
Degrees of Freedom:
Goodness of Fit: df = k - 1
Independence: df = (r - 1)(c - 1)
Expected Frequency (Independence):
Eᵢⱼ = (Row Total × Column Total) / Grand Total
Cramér's V (Effect Size):
V = √(χ² / (n × (min(r,c) - 1)))
Example Calculation
Test whether gender and product preference are independent (2×3 table):
Observed: [[50, 30, 20], [30, 40, 30]]
Row totals: [100, 100], Col totals: [80, 70, 50]
Grand total: 200
Expected: [[40, 35, 25], [40, 35, 25]]
χ² = (50-40)²/40 + (30-35)²/35 + (20-25)²/25
+ (30-40)²/40 + (40-35)²/35 + (30-25)²/25
= 2.5 + 0.714 + 1.0 + 2.5 + 0.714 + 1.0 = 8.429
df = (2-1)(3-1) = 2
p-value = 0.0148
Cramér's V = √(8.429/(200×1)) = 0.205
Conclusion: Reject H₀ at α=0.05. Gender and preference are associated (small-medium effect).
Chi-Square Critical Values Reference Table
| df | α = 0.10 | α = 0.05 | α = 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 |
| 8 | 13.362 | 15.507 | 20.090 |
| 10 | 15.987 | 18.307 | 23.209 |
Frequently Asked Questions
What is the chi-square test of independence?
The chi-square test of independence determines whether there is a statistically significant association between two categorical variables. It compares observed frequencies in a contingency table to the frequencies expected if the variables were independent. A significant result means the variables are associated, but does not indicate the strength or direction of the relationship — use Cramér's V for effect size.
What is the goodness-of-fit test?
The chi-square goodness-of-fit test determines whether observed frequency data matches a specified theoretical distribution. For example, testing whether a die is fair (expected: equal frequencies), whether data follows a Poisson distribution, or whether survey responses match population proportions. The null hypothesis is that the data follows the expected distribution.
What is Cramér's V and how do I interpret it?
Cramér's V is a measure of association (effect size) for the chi-square test of independence. It ranges from 0 (no association) to 1 (perfect association). Guidelines: V < 0.1 = negligible, 0.1-0.3 = small, 0.3-0.5 = medium, > 0.5 = large. Unlike the chi-square statistic, V is not affected by sample size, making it useful for comparing effect sizes across studies.
What if expected frequencies are less than 5?
The chi-square approximation is unreliable when expected frequencies are too small. The common rule is that all expected values should be ≥ 5 (or at least 80% of cells ≥ 5 with none < 1). Solutions: combine adjacent categories, use Fisher's exact test (for 2×2 tables), use the likelihood ratio test, or collect more data. Yates' continuity correction can help for 2×2 tables.
How do I determine degrees of freedom?
For goodness of fit: df = k - 1, where k is the number of categories. If you estimated parameters from the data, subtract one additional df per parameter. For independence: df = (r-1)(c-1), where r is the number of rows and c is the number of columns. For a 2×2 table, df = 1; for a 3×4 table, df = 6.
Can I use percentages instead of counts?
No. The chi-square test requires raw frequency counts (integers), not percentages or proportions. Using percentages inflates or deflates the chi-square statistic depending on sample size. If you only have percentages, multiply by the total sample size to convert back to counts. The test is sensitive to sample size — larger samples are more likely to find significant results even for small effects.