Chi-Square Independence Calculator

Enter the four cell counts of your 2×2 table to test whether the two variables are associated.

How it is calculated

You enter the four counts of a 2×2 table: a and b in the first row, c and d in the second. For each cell the expected count is row total × column total / N, where N = a + b + c + d. Then χ² = Σ (observed − expected)² / expected over the four cells, with 1 degree of freedom. The p-value is erfc(√(χ² / 2)), computed with a numerical approximation, and Cramér's V is √(χ² / N). It is the plain Pearson test, without Yates' continuity correction, and the tool does not warn about small expected counts. If a whole row or column is zero there is no result. Use actual counts, not percentages.

Worked example

Of 50 people given option one, 30 say yes and 20 say no (a = 30, b = 20); of 50 given option two, 15 say yes and 35 say no (c = 15, d = 35). N = 100, the row totals are 50 and 50 and the column totals are 45 and 55. The expected counts are 22.5, 27.5, 22.5 and 27.5. Then χ² = 7.5²/22.5 + 7.5²/27.5 + 7.5²/22.5 + 7.5²/27.5 = 9.0909. With 1 degree of freedom the p-value is 0.0026, and Cramér's V = √(9.0909 / 100) = 0.3015. The difference is unlikely to be due to chance alone.

Try this example →

Common mistakes

  • Entering percentages or proportions instead of raw counts. The statistic depends on the sample size, so 60% and 30% give a different answer from 30 out of 50 and 15 out of 50.
  • Putting the table in the wrong shape, for example both groups in the same row. Each row should be one group, and each column one outcome, so that the expected counts make sense.
  • Reading a small p-value as a strong effect. A big sample can give p below 0.05 with a tiny Cramér's V; look at both numbers.
  • Using it with very small counts. The tool applies no continuity correction and gives no warning, so for expected counts below about 5 treat the p-value as unreliable.
  • Using it for paired data, such as the same people before and after. This test assumes the observations in the two groups are independent.

About this calculator

A Pearson chi-square test of independence checks whether two categorical variables in a contingency table are statistically associated or independent, by comparing the observed cell counts against the counts you'd expect if there were truly no relationship (expected counts derived from the row and column totals). The test statistic χ² = Σ(observed − expected)²/expected grows larger the more the actual data deviates from that independence assumption, and is compared against a chi-square distribution to get a p-value; Cramér's V then scales that association to a 0-1 effect size that, unlike the p-value, doesn't grow automatically with sample size.

This calculator takes the four cell counts of a 2×2 table and returns the χ² statistic, its p-value, and Cramér's V. Researchers analyzing survey or experimental data with categorical outcomes, market researchers testing whether a campaign response differs by segment, and statistics students working through hypothesis-testing coursework use it to determine whether an observed association between two binary variables — like treatment group and outcome, or gender and preference — is likely real or could plausibly be due to chance.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    A small p-value says an association is unlikely to be chance, not that it is big. For the default table 20, 15, 15, 20 the tool gives a chi-square of 1.4286, p about 0.23 and Cramér's V of 0.14, a weak link that also fails to reach significance. Check that every expected count is at least about 5 before relying on the plain Pearson test. What kind of data are you cross-tabulating?

Popular calculators

All Calculators