Chi-Square Test Calculator
Test whether two categorical variables are related with a chi-square test of independence. Enter the observed counts in a contingency table; the calculator computes the chi-square statistic, expected counts, degrees of freedom, and the exact p-value — no table lookups.
Contingency Table
The Chi-Square Statistic
For each cell, compare what you observed with what independence predicts:
E = (row total × column total) ÷ grand total
χ² = Σ (O − E)² / E
Degrees of freedom are (rows − 1) × (columns − 1). The p-value comes from the chi-square distribution with that df — the probability of seeing a statistic this extreme if the variables were truly independent. This calculator evaluates it directly via the incomplete gamma function, so you get an exact p-value for any df, not just the classic table values.
Critical Values at a Glance
| df | Critical χ² (α=0.05) | Common Use |
|---|
Critical values are the 5% upper-tail cutoffs of the chi-square distribution for each df. df = (rows − 1) × (columns − 1).
How to Use This Calculator (3 Steps)
Case Study
Frequently Asked Questions
What is the chi-square test of independence?
It tests whether two categorical variables are related by comparing observed counts with independence-expected counts.
How do I calculate the chi-square statistic?
E = row×col÷grand per cell, then sum (O−E)²/E. A 2×2 [[45,55],[30,70]] table gives 4.8 with 1 df.
What does the p-value mean?
Probability of a statistic this extreme under independence. p < 0.05 is the usual significance threshold.
What are the assumptions?
Counts (not percentages), independent observations, expected counts ≥ 5 in most cells. Otherwise use Fisher's exact.
What is the critical value of chi-square?
The 5% upper-tail cutoff per df: 1 df → 3.841, 2 df → 5.991, 4 df → 9.488.