Chi-Square Calculator

The chi-square test asks whether observed counts differ from what you would expect by chance. Enter a contingency table to test whether two categorical variables are independent, or supply expected frequencies for a goodness-of-fit test. Expected counts are calculated for you and the assumptions are checked.

Two different tests

The test of independence asks whether two categorical variables are related - does treatment group predict outcome, does region predict preference. Expected counts come from the row and column totals, on the assumption that the variables are unrelated.

The goodness-of-fit test asks whether one set of counts matches a distribution you specify. Leave the expected counts blank and it tests against a uniform distribution, which is what you want for checking whether a die is fair.

The expected-count assumption

Chi-square is an approximation that relies on reasonably large expected counts. The usual guidance is that no expected count should fall below 1, and no more than 20% should fall below 5. When your table breaches that, the p-value is not trustworthy and Fisher's exact test is the right alternative. The calculator flags it when this happens.

Significance is not effect size

Chi-square grows with sample size, so with enough data a negligible association becomes "significant". Cramer's V rescales the result to a 0-1 range that does not depend on n, which makes it the more informative number to report.

Frequently asked questions

How many degrees of freedom does my test have?

For a contingency table it is (rows - 1) x (columns - 1), so a 2x2 table has 1 degree of freedom. For a goodness-of-fit test it is the number of categories minus 1, minus one more for each parameter you estimated from the data.

What if some expected counts are very small?

The chi-square approximation becomes unreliable. The usual rule is that all expected counts should be at least 1 and no more than 20% should be below 5. If yours fail that, use Fisher's exact test instead. The calculator warns you when this happens.

Related tools

Steuervergleich Kanton Zürich — Gemeindesteuern vergleichen (Deutsch)