Chi-Square Test Calculator
Tests whether two categorical variables are associated (independence / homogeneity) in an R×C contingency table, and computes effect sizes, power, and sample size. Includes the Pearson chi-square test, Fisher's exact test for sparse 2×2 tables, and McNemar's test for paired data.
How it works
For a contingency table the calculator compares observed counts to the counts expected under independence and reports the chi-square statistic, degrees of freedom, and p-value, along with effect sizes (phi, Cramér's V) and — for 2×2 tables — odds ratio and relative risk. When any expected cell count falls below 5 it automatically also reports Fisher's exact test. Power and sample size use Cohen's w and a non-central chi-square (normal approximation).
When to use it
- You want to test association or homogeneity between two categorical variables (e.g., treatment arm vs. response category).
- You have a 2×2 table and want odds ratio / relative risk alongside the test.
- You have paired or matched binary data and need McNemar's test, or you are planning sample size for a categorical comparison.
Assumptions & limitations
- The chi-square test is an independence/homogeneity test, not a goodness-of-fit test; it assumes independent observations and expected counts of roughly 5 or more per cell. For sparse 2×2 tables, use the reported Fisher's exact result; for larger sparse tables, consider combining defensible categories or using an exact or Monte Carlo method outside this calculator.
- Yates' continuity correction is always applied to 2×2 tables, which is conservative; some references prefer the uncorrected statistic or an exact test.
- Odds ratio, relative risk, and Fisher's exact are available for 2×2 tables only.
- McNemar's test uses the uncorrected asymptotic form and is unreliable when the number of discordant pairs is small; power and sample size rely on a normal approximation rather than an exact calculation.
For the full methodology, derivation, and worked examples, read the complete guide.