Chi-Square Calculator: Goodness of Fit and Independence Test

Chi-Square Calculator

Run a chi-square goodness-of-fit test or test of independence, with the statistic, degrees of freedom, p-value, critical value, expected counts, and effect size.

Separate counts with commas, semicolons, spaces, or new lines. If expected counts are blank, equal proportions are used.


Chi-square formulas

Both tests use χ² = Σ(O−E)²/E, where O is an observed count and E is its expected count. For goodness of fit, degrees of freedom are k−1. For an r×c contingency table, df=(r−1)(c−1) and each expected count is (row total × column total) / grand total.

The p-value is the upper-tail probability from the chi-square distribution. The critical value is the point with upper-tail area α. Effect size is Cohen's w for goodness of fit and Cramér's V for independence.

Checked examples

TestInputsResult
Goodness of fit, equalObserved 10,20,30χ²=10; df=2; p≈0.00673795
Goodness of fit, suppliedObserved 20,30,50; expected 25,25,50χ²=2; df=2; p≈0.367879
Perfect fitObserved 5,5,5; expected 5,5,5χ²=0; p=1
2×2 independence20,10 / 10,20χ²≈6.66667; df=1; p≈0.00982327
Proportional table10,20 / 20,40χ²=0; p=1
2×3 independence12,8,10 / 6,14,10χ²≈3.63636; df=2; p≈0.162321

How to use the calculator

  1. Choose goodness of fit for one categorical variable, or independence for a contingency table.
  2. Enter nonnegative observed counts. For goodness of fit, supply expected counts or leave them blank for equal proportions.
  3. Select α and calculate.
  4. Review χ², p, the critical value, degrees of freedom, and effect size.
  5. Check the expected-count diagnostic before interpreting the result.

Choosing the correct chi-square test

  • Goodness of fit compares observed category counts with a specified distribution.
  • Independence evaluates whether two categorical variables are associated.
  • Enter counts, not percentages, means, measurements, or already-normalized proportions.
  • Observations should be independent; each observation belongs to one cell.

Limits and assumptions

  • Goodness of fit accepts 2–100 categories. Contingency tables accept 2–20 rows and 2–20 columns.
  • Expected and observed totals must match for supplied goodness-of-fit expectations.
  • A common guideline is that expected counts should generally be at least 5. The calculator reports cells below 5 but does not automatically switch to an exact test.
  • The p-value uses the regularized upper incomplete gamma function; the critical value is inverted numerically.
  • A small p-value indicates evidence against the null model, not the strength or cause of an association.

Frequently asked questions

What is the null hypothesis?

For goodness of fit, the null says the observed categories follow the expected distribution. For independence, it says the row and column variables are independent.

What if an expected count is below 5?

The chi-square approximation may be unreliable, especially in small or sparse tables. Consider combining defensible categories or using an appropriate exact method.

What do Cohen's w and Cramér's V show?

They summarize effect size separately from statistical significance. Larger values indicate a larger departure from the null pattern, subject to context.

Can I enter percentages?

No. Enter actual frequency counts. Percentages omit sample size, which is essential to the chi-square statistic.

Related calculators

Use the Probability Calculator for event probabilities, the T-Test Calculator for means, the Standard Deviation Calculator for numerical summaries, or the Sample Size Calculator to plan categorical studies before collecting data.