All Tools

Chi-Square Test of Independence

Enter observed frequencies in a contingency table (up to 4x4) to test whether two categorical variables are independent. The calculator shows expected frequencies, chi-square statistic, p-value, and Cramer's V effect size.

Observed vs Expected

08152330Row 1Row 2ObservedExpected

Contingency Table

Col 1Col 2
Row 1
Row 2

Results

Chi-Square Statistic
11.43
Degrees of Freedom
1
P-value
0.0007232
Cramer's V (effect size)
0.378 (medium)
Decision (alpha = 0.05): Reject the null hypothesis. The variables are not independent.

Expected Frequencies

2318
2318

Step-by-Step Calculation

1. Expected Frequencies

Eij=Ri×CjNE_{ij} = \frac{R_i \times C_j}{N}
E11=40×4580=22.5E_{11} = \frac{40 \times 45}{80} = 22.5
(computed for all 2 \times2 cells)\text{(computed for all 2 \times 2 cells)}

2. Cell Contributions

(OijEij)2Eij\frac{(O_{ij} - E_{ij})^2}{E_{ij}}
(3022.5)222.5=2.5,(1017.5)217.5=3.214,(1522.5)222.5=2.5,(2517.5)217.5=3.214\frac{(30 - 22.5)^2}{22.5} = 2.5, \quad \frac{(10 - 17.5)^2}{17.5} = 3.214, \quad \frac{(15 - 22.5)^2}{22.5} = 2.5, \quad \frac{(25 - 17.5)^2}{17.5} = 3.214

3. Chi-Square Statistic

χ2=i,j(OijEij)2Eij\chi^2 = \sum_{i,j} \frac{(O_{ij} - E_{ij})^2}{E_{ij}}
χ2=sum of all cell contributions\chi^2 = \text{sum of all cell contributions}
χ2=11.43\chi^2 = 11.43

4. Degrees of Freedom

df=(r1)(c1)df = (r - 1)(c - 1)
df=(21)(21)df = (2 - 1)(2 - 1)
df=1df = 1

5. P-value and Decision

p=P(χ12>11.43)p = P(\chi^2_{1} > 11.43)
p=0.0007232p = 0.0007232
p<α=0.05    Reject H0p < \alpha = 0.05 \implies \text{Reject } H_0

6. Cramer's V

V=χ2Nmin(r1,c1)V = \sqrt{\frac{\chi^2}{N \cdot \min(r-1, c-1)}}
V=11.43801V = \sqrt{\frac{11.43}{80 \cdot 1}}
V=0.378V = 0.378

Reference Guide

The Chi-Square Test

The chi-square test of independence checks whether two categorical variables are related or independent. It compares observed counts to the counts you would expect if the variables were independent.

χ2=(OijEij)2Eij\chi^2 = \sum \frac{(O_{ij} - E_{ij})^2}{E_{ij}}

Expected Frequencies

Under the null hypothesis (no association), the expected count for each cell is calculated from the row and column totals.

Eij=Ri×CjNE_{ij} = \frac{R_i \times C_j}{N}

As a rule of thumb, all expected frequencies should be at least 5 for the test to be reliable.

Cramer's V

Cramer's V measures the strength of association between the two variables. It ranges from 0 (no association) to 1 (perfect association).

V=χ2Nmin(r1,c1)V = \sqrt{\frac{\chi^2}{N \cdot \min(r-1, c-1)}}

Guidelines: below 0.1 is negligible, 0.1 to 0.3 is small, 0.3 to 0.5 is medium, and above 0.5 is large.

When to Use This Test

Use this test when you have count data for two categorical variables and want to know if they are related. Common examples include survey responses by demographic group, A/B test results, and medical study outcomes.

The test requires independent observations and sufficiently large expected counts (typically 5 or more per cell).