Chi-Square Test of Independence Calculator
Run a chi-square test of independence on a contingency table to see whether two categorical variables are statistically associated.
Degrees of freedom: 1 · p-value: 0.0026
- 1
Grand total N
100 - 2
Degrees of freedom (r−1)(c−1)
(2 − 1) × (2 − 1) = 1 - 3
Chi-square χ² = ΣΣ (O − E)² ÷ E
Sum over 2 × 2 cells = 9.0909Each cell's expected count Eᵢⱼ = row total × column total ÷ N; large residuals drive χ² up.
How does this calculator work?
The chi-square test of independence checks whether two categorical variables are associated. From your contingency table it computes χ² = ΣΣ(O−E)²/E with E = row·column/N, degrees of freedom (r−1)(c−1), an upper-tail p-value, and Cramér's V. A small p-value signals a real association.
Formula
How this is calculated
Enter your observed counts as a contingency table: one row per line, with cell values separated by spaces or commas. Every row must have the same number of columns, and all counts must be zero or positive integers. The calculator reads the r×c matrix of observed frequencies Oᵢⱼ.
It computes each row total Rᵢ, each column total Cⱼ, and the grand total N. Under the null hypothesis that the two variables are independent, the expected count in each cell is Eᵢⱼ = Rᵢ·Cⱼ / N. The chi-square statistic sums the squared standardized residuals, χ² = ΣΣ (Oᵢⱼ − Eᵢⱼ)² / Eᵢⱼ, with degrees of freedom df = (r−1)(c−1). The p-value is the upper-tail probability of the chi-square distribution, computed here from the regularized incomplete gamma function.
Cramér's V = √(χ² / (N·min(r−1, c−1))) rescales χ² into a 0–1 effect-size measure of association strength. The test assumes independent observations and that expected counts are reasonably large (a common rule of thumb is Eᵢⱼ ≥ 5); with very small expected counts the chi-square approximation is unreliable and an exact test such as Fisher's is preferred. A small p-value (e.g. < 0.05) indicates evidence of association between the variables.
Frequently asked questions
Put each row of observed counts on its own line, separating the cells with spaces or commas. For a 2×2 table you write two lines of two numbers each. Every row must contain the same number of columns.
Cramér's V is an effect size from 0 to 1 measuring how strongly the two variables are associated. Roughly, 0.1 is a small effect, 0.3 is moderate, and 0.5 or more is large. Unlike the p-value, it does not depend directly on sample size.
The test relies on a large-sample approximation, so it can be inaccurate when expected cell counts are small (commonly below 5). In that case use Fisher's exact test, and always ensure observations are independent.
Also known as
TG we-Calculate Editorial Team. (2026). Chi-Square Test of Independence Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/chi-square-test-of-independence-calculator
TG we-Calculate Editorial Team. "Chi-Square Test of Independence Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/chi-square-test-of-independence-calculator.
TG we-Calculate Editorial Team, "Chi-Square Test of Independence Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/chi-square-test-of-independence-calculator
@misc{wecalculate_chi_square_test_of_independence_calculator, title = {Chi-Square Test of Independence Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/chi-square-test-of-independence-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
