Chi-square test of independence calculator
Test whether two categorical variables are related, with Cramér’s V.
Calculator inputs
Results
Enter your values and press “Calculate” to see the result.
In short
- What it calculates
- Test whether two categorical variables are related, with Cramér’s V.
- Formula used
Expected = (row total × column total) / N- Example
- 2×2 table:
Chi-square calculator
Chi-square compares the frequencies you observed with those you would expect if the two variables were independent.
It is the standard test for contingency tables in surveys and studies with categorical variables.
How it works
For each cell the expected frequency is derived from the marginal totals, and the squared difference relative to that expectation is accumulated.
Cramér's V rescales the result between 0 and 1, because chi-square grows with sample size.
Formula
Expected = (row total × column total) / N
χ² = Σ (observed − expected)² / expected
df = (rows − 1) × (columns − 1)
Cramér's V = √( χ² / (N · min(r−1, c−1)) )
Worked example
2×2 table:
30 20
15 35
χ² = 9.09 with 1 df
p = 0.0026
Cramér's V = 0.30 → moderate, significant association
Explanation
What it is actually testing
The test compares what you observed with what would be expected if there were no relationship between the variables. If the discrepancy is large, independence is judged implausible. It does not measure the strength of the association, only whether chance is a reasonable explanation.
A significant result is not an important result
With very large samples, tiny differences of no practical relevance come out significant. That is why the test should be accompanied by a measure of effect size, such as Cramér's V, which does indicate how strong the association is on a scale from zero to one.
Expected frequencies rule
The approximation stops being reliable when expected frequencies are very small. The usual rule asks that they all exceed 5, or at least that the great majority do. In two-by-two tables with sparse cells, Fisher's exact test is the correct alternative.
Independence of observations
Each individual must appear in only one cell. If you measure the same people before and after, the data are paired and McNemar's test is needed instead.
Frequently asked questions
What if an expected frequency is below 5?
The approximation loses validity. That is why the minimum expected frequency is shown: if it drops under 5, merge categories or use Fisher’s exact test.
Does a significant chi-square imply causation?
No. It only shows the variables are not independent; direction and cause require different analysis.
What if I have cells with few cases?
In two-by-two tables, use Fisher’s exact test. In larger tables, merge infrequent categories until expected frequencies are adequate.
How do I know if the association is strong?
With an effect size measure such as Cramér’s V. The p-value only indicates whether chance is a credible explanation, not the magnitude.
Need to calculate something else?
These tools are often used alongside this calculator.
t test
Compare two group means, paired samples, or one sample against a value.
Pearson
The r coefficient, R², p value and an interpretation of the strength.
Sample size
How many responses you need for your survey to be representative.
Standard deviation
Sample and population deviation, variance and coefficient of variation.
Margin of error
How precise your survey is, given the sample you actually collected.
Z score
How many standard deviations a value sits from the mean and which percentile it occupies.