What Is Chi-Square Test?
A chi-square test compares observed counts with the counts you would expect if a hypothesis were true. A goodness-of-fit test checks one categorical variable against expected proportions; a test of independence checks whether two categorical variables in a table are associated.
The calculator shows the expected count for every cell, flags cells with an expected count below 5, and reports Cramér's V as an effect size, so you can judge how large the association is as well as whether it is statistically significant.
Below you will find the formulas, a variables table, a worked example and answers to common questions such as how to find degrees of freedom and what to do when expected counts are small.
How to Use the Chi-Square Test Calculator
- Choose independence (a table of counts) or goodness of fit (a single list).
- Enter the observed counts. For goodness of fit you may add expected proportions; leave blank for equal expectation.
- Select α. Read the p-value and decision.
- Check the standardised residuals: cells with absolute values above about 2 are the ones that differ most from expectation.
Chi-Square Test Formula
Chi-square statistic
Expected count in a contingency table
Degrees of freedom
Cramér’s V
Standardised residual
Chi-Square Test Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| χ² | Chi-square statistic | Σ (O − E)² ÷ E |
| O | Observed count | From your data |
| E | Expected count | Row total × column total ÷ N |
| df | Degrees of freedom | (rows − 1)(columns − 1), or categories − 1 |
| V | Cramér's V | Effect size from 0 to 1 |
Chi-Square Test Worked Example
Using the example values (press “Load example” above to try them):
- Row totals: 60, 80; column totals: 50, 55, 35; grand total 140.
- Expected count for each cell = (row total × column total) ÷ grand total.
- χ² = Σ (O − E)² ÷ E = 9.86364.
- Degrees of freedom = (2 − 1)(3 − 1) = 2.
- p-value = P(χ²(2) ≥ 9.8636) = 0.0072134; critical value = 5.9915.
- p < α, so we reject H₀.
Result: Chi-square statistic χ² = 9.86364; p-value = 0.0072134; Decision at α = 0.05 = Reject H₀.
Goodness of fit vs independence vs homogeneity
Independence and homogeneity use exactly the same calculation, so this tool covers both; the difference is in how the data were collected and how you word the conclusion.
| Test | Question | Data |
|---|---|---|
| Goodness of fit | Does one variable match a given distribution? | One list of category counts |
| Independence | Are two variables associated? | One sample, cross-classified in a table |
| Homogeneity | Do several populations share the same distribution? | Separate samples, same table layout |
Effect size: Cramér’s V
A significant chi-square only says an association exists; with a big sample even a tiny association is significant. Cramér’s V rescales χ² to a 0–1 range so you can judge strength.
| min(r, c) − 1 | Small | Medium | Large |
|---|---|---|---|
| 1 | 0.10 | 0.30 | 0.50 |
| 2 | 0.07 | 0.21 | 0.35 |
| 3 | 0.06 | 0.17 | 0.29 |
Assumptions and when the test is unreliable
- Counts, not percentages or means: enter raw frequencies.
- Independent observations: each subject appears in only one cell.
- Expected counts of at least 5 in most cells (rule of thumb: all at least 1 and no more than 20% below 5).
- For a 2 × 2 table with small expected counts use Fisher’s exact test; the Yates correction shown here is a more conservative alternative.
- Categories must be mutually exclusive and cover all cases.
Finding where the difference is
A significant overall result does not say which cells are responsible. The standardised residual compares each cell’s observed count with expectation in standard-deviation-like units. Values beyond ±2 are unusual, beyond ±3 very unusual. With many cells a few will exceed 2 by chance, so adjust the threshold (for example Bonferroni) when scanning large tables.
Where Chi-Square Test Is Used
Survey cross-tabs
Checking whether answers differ between groups, such as age band and preference.
Fairness checks
Testing whether observed counts match expected proportions, such as a die or a split of categories.
Classroom problems
Working a contingency-table problem with expected counts and residuals shown.
Reporting an association
Giving the statistic, df, p-value and Cramér's V together.
Common Chi-Square Test Mistakes to Avoid
- Never enter percentages; convert back to counts first.
- Merge sparse categories sensibly if expected counts are too small.
- Report χ², df, N, p and Cramér’s V together.
- A non-significant result does not prove independence, especially in small samples.
Chi-Square Test Terms and Definitions
- Observed count
- The number of cases actually counted in a cell.
- Expected count
- The count predicted by the null hypothesis.
- Contingency table
- A cross-tabulation of two categorical variables.
Chi-Square Test FAQs
What does a chi-square test tell you?
Whether observed category counts differ from expected counts by more than chance, either against a stated distribution or for an association between two variables.
How do I calculate chi-square by hand?
For each cell subtract the expected count from the observed count, square it, divide by the expected count and add the results.
What are the degrees of freedom?
For goodness of fit, categories minus 1. For a contingency table, (rows − 1) × (columns − 1).
What is a good p-value for chi-square?
A p-value below your α (commonly 0.05) indicates a statistically significant difference or association. The p-value does not tell you the strength of the association; use Cramér’s V.
Can I use percentages?
No. The test needs raw counts because the sample size determines the evidence. Convert percentages back to counts if you know the total.
What if my expected counts are below 5?
Combine categories if sensible, collect more data, or use an exact test such as Fisher’s for 2 × 2 tables.
What is the difference between chi-square and a t-test?
Chi-square analyses counts in categories; a t-test compares means of numeric data.
What should I do if expected counts are below 5?
The chi-square approximation can be unreliable when expected counts are small. Combine categories where that makes sense, collect more data, or use an exact test such as Fisher's exact test for a 2×2 table. The calculator flags cells with an expected count below 5.
How do I find the p-value or critical value for my chi-square?
The calculator reports the p-value for your table. To look up a p-value or critical value for any statistic and degrees of freedom, use the chi-square p-value calculator linked below.