Chi-Square Test Calculator
Type a contingency table of counts, or a list of observed frequencies, and get χ², the degrees of freedom, and an exact p-value — with the expected counts, Cramér's V or Cohen's w, and the working shown. The calculator warns you when expected counts are too small for the chi-square approximation to be trusted. Free, no sign-up.
Type the observed counts. Row and column names are editable — they label the results.
| Total | |||
|---|---|---|---|
| — | |||
| — | |||
| Total | — | — | — |
Fill every cell with a whole-number count — zero is allowed.
How to Use the Chi-Square Test Calculator
- 1. Pick the test. Choose test of independence when you have two categorical variables cross-tabulated, or goodness of fit when you have one variable and a claimed distribution to compare it with.
- 2. Enter the counts. For independence, type each cell's count and rename the rows and columns; add or remove them to fit anything from 2 × 2 to 8 × 8. For goodness of fit, list the observed counts and, if the categories are not expected to be equal, the expected proportions, percentages, or counts.
- 3. Check the expected counts. The results show every expected count. If any falls below 5, a warning explains the problem and, for a 2 × 2 table, points you to Fisher's exact test.
- 4. Read and report. You get χ², df, the p-value, an effect size, adjusted residuals that show which cells drive an association, the working, and a copy-ready APA line.
Independence or Goodness of Fit?
| Question | Test | Degrees of freedom | Example |
|---|---|---|---|
| Are two categorical variables related? | Test of independence | (r − 1)(c − 1) | Study mode (online, in person, hybrid) by exam outcome (passed, failed) |
| Do one variable's counts match a stated distribution? | Goodness of fit | k − 1 | Which of four essay prompts 100 students chose, against equal shares |
How the Statistic Is Built
Each cell gets an expected count — what you would see if the null hypothesis were exactly true. In a test of independence that is E = (row total × column total) / N; in a goodness-of-fit test it is E = N × p for each category's expected proportion p. The statistic adds up how far each observed count O sits from its expectation, scaled by the expectation: χ² = Σ (O − E)² / E. Large values mean the table is unlikely under H₀, and the p-value is the upper-tail area of the chi-square distribution with the test's degrees of freedom. To look up critical values instead, use the chi-square distribution table.
- Cramér's V = √(χ² / (N(min(r, c) − 1))) runs from 0 (no association) to 1 (perfect association) and lets you compare tables of different sizes.
- φ (phi) = √(χ² / N) is the 2 × 2 special case, where it equals V.
- Cohen's w = √(χ² / N) measures goodness-of-fit departures. Cohen's benchmarks are .10 small, .30 medium, and .50 large; for V, divide those benchmarks by √(min(r, c) − 1).
Worked Example: Study Mode and Pass Rates
Click Try an example to load results for 160 students: online, 45 passed and 15 failed; in person, 30 and 30; hybrid, 25 and 15. Overall 100 of 160 passed, so independence predicts 37.5 passes among the 60 online students (60 × 100 / 160).
Test of independence, step by step
Expected: online 37.5 / 22.5, in person 37.5 / 22.5, hybrid 25 / 15
χ² = 1.5 + 2.5 + 1.5 + 2.5 + 0 + 0 = 8.00
df = (3 − 1)(2 − 1) = 2, p = .018
V = √(8.00 / (160 × 1)) = .22
Reported in APA style: χ²(2, N = 160) = 8.00, p = .018, V = .22. The adjusted residuals locate the association: online students passed more often than independence predicts (+2.53) and in-person students less often (−2.53), while hybrid students matched expectation exactly. Because the table has two columns, min(r, c) − 1 = 1 and Cohen's benchmarks apply to V unchanged, so .22 sits between small (.10) and medium (.30).
When the Approximation Breaks Down
The p-value comes from a large-sample approximation. A common rule (Cochran, 1954) asks that no expected count fall below 1 and no more than 20% fall below 5; the calculator flags any expected count under 5. For a 2 × 2 table with small counts, use Fisher's exact test. Yates's continuity correction is the older fix for 2 × 2 tables: it shrinks χ² and makes the test conservative, so many statisticians now skip it when counts are adequate. R's chisq.test and SciPy's chi2_contingency apply it to 2 × 2 tables by default, which is why their χ² can differ from SPSS's Pearson row — tick or untick the box to match the one you are checking.
- Entering percentages instead of counts. χ² depends on N; percentages throw the sample size away and give a meaningless result.
- Counting one person in two cells. Every observation must land in exactly one cell. Repeated measurements on the same people need McNemar's test or another paired method.
- Reading a small p as a strong association. With a large N, trivial associations become significant — report V or w alongside p.
Frequently Asked Questions
- What does the chi-square test of independence tell you?
- It tests whether two categorical variables are associated in the population — whether the distribution of one changes across the levels of the other. A significant result says the observed table is unlikely if the variables were independent. It does not say how strong the association is (use Cramér's V for that) or which cells are responsible (look at the adjusted residuals).
- How do you calculate expected frequencies for a chi-square test?
- For a contingency table, multiply the cell's row total by its column total and divide by the grand total N. For a goodness-of-fit test, multiply N by each category's expected proportion. Expected counts do not have to be whole numbers — 37.5 is a perfectly good expected count.
- What is a good Cramér's V?
- There is no universal threshold, but Cohen's conventions, adjusted for table size, are the usual reference: for a 2 × 2 table (where V equals φ), about .10 is small, .30 medium, and .50 large. For larger tables divide those values by √(min(r, c) − 1) — in a 3 × 3 table the medium benchmark becomes about .21.
- Should I use Yates's continuity correction?
- Only if your course, journal, or software comparison expects it. The correction applies to 2 × 2 tables only and makes the test conservative — p-values come out too large. With adequate expected counts, the uncorrected Pearson χ² is accurate; with small counts, Fisher's exact test is the better remedy.
- Can I run a chi-square test on percentages or means?
- No. The test needs raw frequencies — the number of cases in each category. Convert percentages back to counts using the group sizes before you enter them; a table of means or scores needs a different test, such as a t-test or ANOVA.
- How do I report a chi-square test in APA style?
- Write χ² with the degrees of freedom and the sample size in parentheses, then the value and p: χ²(2, N = 160) = 8.00, p = .018. Add an effect size such as V = .22. In APA style the Greek χ is not italicised, but N, p, and V are; p has no leading zero, and anything below .001 is written p < .001.