Chi-square test and Cramér's V calculator

Paste a table of counts to test the association between two categorical variables, measure its strength with Cramér's V and see which cells drive it; 2 × 2 tables add Fisher's exact test, odds ratio and relative risk.

No accountInstant resultsAny r × c table

Enter the contingency table

Counts of cases in each combination of two categorical variables.

OBSERVED COUNTS

LIVE RESULT

INSTANT

Chi-square test and effect size

Counts must come from independent observations, each case counted once. For paired or repeated measurements, such as before and after, use McNemar's test instead.

Testing an association between two categorical variables

The chi-square test of independence compares the observed counts with the counts expected if the two variables were unrelated. A p-value says whether the association could plausibly be chance; Cramér's V says how strong it is, on a scale from 0 (no association) to 1 (each category of one variable fully determines the other).

Expected count E = row total × column total ÷ N
χ² = Σ (O − E)² ÷ E, df = (r − 1)(c − 1)
Cramér's V = √(χ² ÷ (N × (min(r, c) − 1))); for a 2 × 2 table V = |φ|
Adjusted residual = (O − E) ÷ √(E (1 − row share)(1 − column share))

The calculator also reports the likelihood-ratio statistic G², the contingency coefficient and Bergsma's bias-corrected V, which is less inflated in small samples. Results match SciPy's chi2_contingency, fisher_exact and association functions and statsmodels' 2 × 2 table.

Worked example

In the 3 × 3 example, χ²(4, N = 175) = 23.78, p < .001, Cramér's V = 0.26. The adjusted residuals in the table below the calculator show where the association comes from: cells beyond ±1.96 have clearly more (positive) or fewer (negative) cases than expected. Here the first row is over-represented in the first column (4.46) and the last row in the last column (2.47).

2 × 2 tables

For a 2 × 2 table the calculator adds φ, Yates' continuity correction, Fisher's exact test, the odds ratio and the relative risk with confidence intervals. In a trial where 12 of 17 treated and 3 of 18 control participants improved, χ²(1) = 10.38, p = .001; Fisher's exact p = .002; the odds ratio is 12.00, 95% CI [2.37, 60.65], and the relative risk 4.24, [1.44, 12.44]. The odds ratio looks much larger than the relative risk because improvement is common; in most fields the relative risk or risk difference is easier to explain.

How large is Cramér's V?

Cohen's benchmarks by the smaller table dimension
min(r, c) − 1SmallMediumLarge
1 (2 × 2, 2 × c)0.100.300.50
20.070.210.35
30.060.170.29
40.050.150.25

The same V means a stronger association in a larger table, so the benchmarks shrink as the table grows.

When the chi-square test is not appropriate

  • Small expected counts. The chi-square approximation needs most expected counts of at least 5 and none below 1. For a 2 × 2 table with small counts, use Fisher's exact test; for larger tables, combine sparse categories or use an exact or simulated test. The calculator warns when expected counts are low.
  • Percentages. Enter the counts, not percentages: the test depends on the sample size.
  • Ordered categories. If both variables are ordinal, a test for trend or a rank correlation has more power than the chi-square test.

To compute the p-value of a published χ² statistic, use the p-value calculator; to convert an odds ratio into Cohen's d, use the effect size converter.