Chi Square Test CalculatorTest of Independence and Goodness of Fit, with Steps
Enter your observed counts and get the chi-square statistic, degrees of freedom, p-value and critical value instantly. You also get expected frequencies, Cramér’s V, cell-by-cell residuals, an assumption check and a ready-to-paste APA sentence.
The calculator uses Pearson’s method, with Yates’ 1934 correction and the expected-count guidance in Penn State STAT 500 and the NIST/SEMATECH e-Handbook. All math runs in your browser, so your data never leaves your device.
What is a chi-square test?
A chi-square (χ²) test checks whether observed category counts differ from the counts you would expect by chance. The statistic is χ² = Σ (O − E)² / E. You compare it with a chi-square distribution that has (rows − 1) × (columns − 1) degrees of freedom for independence, or k − 1 for goodness of fit. If p ≤ α (usually 0.05), the difference is statistically significant.
Click a grey header to rename a row or column. Enter whole-number frequencies only, never percentages.
Paste a table from Excel or Google Sheets
Separate values with tabs, commas, semicolons or spaces. A first row or column of text is read as labels.
Leave this at 0 unless you estimated parameters from the same data, for example a Poisson mean (m = 1). df = k − 1 − m.
Use this mode when software or a textbook already gives you χ² and df, and you only need the right-tail p-value and critical value.
Results update as you type.
Enter your counts
Your verdict appears here.
Chi-square distribution
The curve shows where your statistic falls relative to the critical value.
Observed vs expected counts
Each cell shows the observed count with the expected count beneath it.
Which cells drive the result? Adjusted residuals
Coral cells hold more cases than expected and teal cells hold fewer. Outlined cells pass the Bonferroni-adjusted cut-off.
Contribution to χ²
The share of the total statistic each cell adds through (O − E)² / E.
Assumption check
Report it (APA 7th edition style)
What this means
Step-by-step solution
How to Use This Chi Square Test Calculator
The tool runs three related procedures. Pick the tab that matches your question, then follow these steps.
- Choose the test. Use Test of Independence when you have two categorical variables in a contingency table, such as treatment by outcome. Use Goodness of Fit when you have one variable to compare against a claimed distribution. Use P-value from χ² when you already know the statistic.
- Set α. The default of 0.05 suits most coursework and research. Pick 0.01 or 0.001 for stricter claims.
- Enter observed counts. Size the grid with the row and column steppers, or paste a table straight from Excel or Google Sheets. Rename the headers so your residuals and APA sentence read naturally.
- Read the verdict and the p-value meter. If the white dot sits right of the teal α line, the result is significant.
- Check effect size and residuals. Cramér’s V or Cohen’s w tells you how strong the pattern is. The heatmap shows which cells create it.
- Review the assumption check. If too many expected counts fall below 5, follow the suggested alternative before you report.
Chi-Square Formula and Degrees of Freedom
Every chi-square test compares what you observed (O) with what the null hypothesis predicts (E). Squaring each gap removes the sign. Dividing by E scales each gap to the size of that cell. Adding the pieces gives one number that grows as the data drift from the null.
O = observed count, E = expected count, N = grand total, r = rows, c = columns, k = categories, m = parameters estimated from the data.
Yates’ continuity correction
The χ² distribution is continuous, but counts are not. In a 2 × 2 table, this mismatch makes the uncorrected test slightly too eager to reject. Frank Yates proposed subtracting 0.5 from each absolute gap: χ²Y = Σ (|O − E| − 0.5)² / E. The correction is conservative, so many statisticians now prefer the uncorrected test for adequate samples and Fisher’s exact test for small ones. This calculator lets you toggle it and always shows both values in the steps.
Effect size: Cramér’s V and Cohen’s w
A p-value tells you whether an association exists, not how strong it is. With large samples, even trivial differences become significant. Report an effect size alongside every χ². (For numeric outcomes compared between two groups, the equivalent measure is Cohen’s d.)
Test of Independence vs Homogeneity vs Goodness of Fit
All three use the same formula. They differ in how the data were collected and in what the null hypothesis claims.
| Test | Question it answers | Data layout | Null hypothesis (H₀) | df |
|---|---|---|---|---|
| Independence | Are two categorical variables related in one population? | One sample, cross-classified into an R × C table | The variables are independent | (r − 1)(c − 1) |
| Homogeneity | Do several populations share the same distribution? | Separate samples, one per row | Category proportions are equal across groups | (r − 1)(c − 1) |
| Goodness of fit | Does one variable follow a claimed distribution? | One row of k category counts | Observed proportions match the expected ones | k − 1 − m |
The arithmetic for homogeneity and independence is identical, so use the Test of Independence tab for both. Only the wording of your conclusion changes. If both of your variables are numeric rather than categorical, you need a correlation coefficient instead of a chi-square test.
Worked Example: Chi-Square Test of Independence
This illustrative dataset is the calculator’s default. A community pharmacy wants to know whether a reminder text message changes how patients collect refills. It follows 320 refill orders, half with an SMS reminder and half without, and records whether each refill was picked up on time, picked up late or not picked up.
| Observed (expected) | On time | Late | Not picked up | Row total |
|---|---|---|---|---|
| Reminder SMS | 112 (98) | 28 (32) | 20 (30) | 160 |
| No reminder | 84 (98) | 36 (32) | 40 (30) | 160 |
| Column total | 196 | 64 | 60 | N = 320 |
- Expected counts. For the top-left cell, E = 160 × 196 / 320 = 98. Both rows have 160 orders, so each row gets the same expected values: 98, 32 and 30.
- Cell contributions. (112 − 98)² / 98 = 2.000; (28 − 32)² / 32 = 0.500; (20 − 30)² / 30 = 3.333. The second row mirrors the first, giving the same three values.
- Sum. χ² = 2(2.000 + 0.500 + 3.333) = 11.667.
- Degrees of freedom. df = (2 − 1)(3 − 1) = 2. The critical value at α = 0.05 is 5.991.
- p-value. The right-tail area beyond 11.667 with 2 df is p ≈ 0.0029, well below 0.05, so you reject H₀.
- Effect size. Cramér’s V = √(11.667 / (320 × 1)) = 0.19, a small association by Cohen’s benchmarks for a table with min(r, c) − 1 = 1.
- Where the effect lives. The adjusted residuals for “Reminder × On time” (+3.21) and “Reminder × Not picked up” (−2.86) both exceed the Bonferroni cut-off of ±2.64 for six cells. The “Late” column (±1.12) does not.
Plain-language conclusion: In this example, refill pickup behaviour depends on the reminder. More reminded patients collected on time and fewer never collected, but the effect is modest (V = 0.19).
Worked example: goodness of fit
A shop logs 180 customer visits: Monday 42, Tuesday 30, Wednesday 28, Thursday 35 and Friday 45. If visits were spread evenly, each day would expect 36. That gives χ² = 1.00 + 1.00 + 1.78 + 0.03 + 2.25 = 6.06 with df = 4, p ≈ 0.195 and Cohen’s w = 0.18. The difference is not significant, so the data are consistent with an even weekday spread. Load it with Try an example on the Goodness of Fit tab.
How to Interpret Chi-Square Results
p-value and critical value give the same decision
The p-value is the probability of a χ² at least this large if H₀ were true. If p ≤ α, reject H₀. Equivalently, if χ² ≥ the critical value for your df and α, reject H₀. The calculator shows both so you can match whichever method your course uses. Chi-square tests are right-tailed by design, because only large discrepancies count as evidence against H₀.
Effect size benchmarks
Cohen’s benchmarks for w are 0.10 (small), 0.30 (medium) and 0.50 (large). For Cramér’s V, divide them by √(min(r, c) − 1), so the bar drops as the table grows:
| min(r, c) − 1 | Small | Medium | Large | Example table |
|---|---|---|---|---|
| 1 | 0.10 | 0.30 | 0.50 | 2 × 2, 2 × 5 |
| 2 | 0.07 | 0.21 | 0.35 | 3 × 3, 3 × 4 |
| 3 | 0.06 | 0.17 | 0.29 | 4 × 4, 4 × 6 |
| 4 | 0.05 | 0.15 | 0.25 | 5 × 5 |
Post-hoc analysis with adjusted residuals
A significant χ² on a table larger than 2 × 2 says only that some association exists somewhere. Adjusted standardized residuals, (O − E) / √(E(1 − rowᵢ/N)(1 − colⱼ/N)), follow an approximately standard normal distribution under H₀. A value beyond ±1.96 flags a cell at α = 0.05. Testing every cell at once inflates false positives, so the calculator also applies a Bonferroni-adjusted cut-off based on the number of cells, as Sharpe (2015) recommends.
Chi-Square Test Assumptions (and What to Do When They Fail)
- Counts, not percentages or means. The test is built on frequencies. Converting to percentages hides the sample size, and the result becomes meaningless.
- Independent observations. Each subject appears in exactly one cell. For before-and-after data on the same people, use McNemar’s test instead.
- Mutually exclusive categories. No subject can fall into two columns.
- Adequate expected counts. Cochran’s widely used rule asks that no expected count fall below 1 and that no more than 20% fall below 5. For a 2 × 2 table, every expected count should ideally be 5 or more.
If the expected-count rule fails: for a 2 × 2 table, switch to the Fisher Exact Test Calculator, which computes an exact p-value with no large-sample approximation. For bigger tables, merge sparse categories when it makes substantive sense, or collect more data. The assumption panel above flags this automatically.
Chi-Square Critical Value Table
These right-tail critical values come from the same engine that powers the calculator. Reject H₀ when your χ² is greater than or equal to the value for your df and α. For any df not listed, use the P-value from χ² tab.
| df | α = 0.10 | α = 0.05 | α = 0.025 | α = 0.01 | α = 0.001 |
|---|---|---|---|---|---|
| 1 | 2.706 | 3.841 | 5.024 | 6.635 | 10.828 |
| 2 | 4.605 | 5.991 | 7.378 | 9.210 | 13.816 |
| 3 | 6.251 | 7.815 | 9.348 | 11.345 | 16.266 |
| 4 | 7.779 | 9.488 | 11.143 | 13.277 | 18.467 |
| 5 | 9.236 | 11.070 | 12.833 | 15.086 | 20.515 |
| 6 | 10.645 | 12.592 | 14.449 | 16.812 | 22.458 |
| 7 | 12.017 | 14.067 | 16.013 | 18.475 | 24.322 |
| 8 | 13.362 | 15.507 | 17.535 | 20.090 | 26.124 |
| 9 | 14.684 | 16.919 | 19.023 | 21.666 | 27.877 |
| 10 | 15.987 | 18.307 | 20.483 | 23.209 | 29.588 |
| 12 | 18.549 | 21.026 | 23.337 | 26.217 | 32.909 |
| 15 | 22.307 | 24.996 | 27.488 | 30.578 | 37.697 |
| 20 | 28.412 | 31.410 | 34.170 | 37.566 | 45.315 |
| 25 | 34.382 | 37.652 | 40.646 | 44.314 | 52.620 |
| 30 | 40.256 | 43.773 | 46.979 | 50.892 | 59.703 |
How to Report a Chi-Square Test in APA Format
APA style reports the statistic with its degrees of freedom and sample size, the exact p-value to three decimals (or p < .001), and an effect size. Italicize p and N, and drop the leading zero for values that cannot exceed 1:
A chi-square test of independence showed a significant association between reminder type and pickup status, χ²(2, N = 320) = 11.67, p = .003, Cramér’s V = .19.
The calculator writes this sentence for your own data, including the non-significant wording and the correct test name for goodness of fit. Add the residual findings in a second sentence when they matter to your question.
Common Chi-Square Mistakes to Avoid
- Entering percentages or proportions as counts. A table of percentages inflates or deflates χ² depending on the real N.
- Calling a significant result a strong one. With 10,000 respondents, V = 0.03 can reach p < .001. Always pair p with V or w.
- Using the wrong df for goodness of fit. If you estimated a parameter from the same data, such as a Poisson mean, subtract it as well: df = k − 1 − m.
- Ignoring sparse cells. Expected counts below 5 make the χ² approximation unreliable, even when the total N looks large.
- Treating repeated measures as independent. Paired yes/no data need McNemar’s test, not Pearson’s χ².
- Stopping at “significant.” On larger tables, report which cells drive the association using residuals.
Related Statistics Calculators
A chi-square test is usually one step in a larger analysis. These tools cover the steps before and after it.
Frequently Asked Questions
It takes a table of observed counts and computes the expected counts, the chi-square statistic, the degrees of freedom and the p-value. It then tells you whether the pattern is statistically significant. This calculator also reports Cramér’s V or Cohen’s w, adjusted residuals, an assumption check and an APA-style results sentence.
First compute each expected count as row total times column total divided by the grand total. For every cell, subtract the expected count from the observed count, square the result and divide by the expected count. Add all of these values to get χ². Then compare it with the critical value for your degrees of freedom, or convert it to a p-value.
For a test of independence or homogeneity, df equals (number of rows − 1) × (number of columns − 1), so a 2 × 3 table has 2 df. For a goodness-of-fit test, df equals the number of categories − 1, minus one more for each parameter you estimated from the same data.
The test of independence uses a two-way contingency table and asks whether two categorical variables are related. The goodness-of-fit test uses a single categorical variable and asks whether its counts match a claimed distribution, such as equal proportions or a genetic ratio.
The p-value is the probability of getting a chi-square statistic this large or larger if the null hypothesis were true. If it is at or below your significance level, usually 0.05, you reject the null hypothesis and conclude there is a significant association or misfit. A large p-value means the data are consistent with the null hypothesis, not that the null hypothesis is proven.
It depends on the degrees of freedom. At α = 0.05 the critical value is 3.841 for 1 df, 5.991 for 2 df, 7.815 for 3 df, 9.488 for 4 df and 11.070 for 5 df. The table on this page lists values up to 30 df, and the P-value tab handles any df.
Yates’ correction applies only to 2 × 2 tables. It subtracts 0.5 from each absolute difference between observed and expected counts, which makes the test more conservative. Some textbooks and software apply it by default. For small samples, Fisher’s exact test is usually the better choice, and for large samples the correction makes little difference.
The chi-square approximation becomes unreliable when expected counts are small. A common rule is that no expected count should be below 1 and no more than 20 percent should be below 5. If your table breaks this rule, use Fisher’s exact test for a 2 × 2 table, or merge sparse categories or collect more data for larger tables.
No. The chi-square statistic depends directly on the sample size, so it must be calculated from raw frequencies. If you only have percentages, convert them back to counts by multiplying each percentage by the number of observations in its group.
Cramér’s V is an effect size for contingency tables, calculated as the square root of χ² divided by N times (the smaller of rows or columns minus 1). It ranges from 0, no association, to 1, perfect association. Unlike the p-value, it does not grow with sample size, so it shows how strong the relationship actually is.
Look at the adjusted standardized residuals. Cells with residuals beyond about ±1.96 deviate from independence at the 0.05 level, and positive values mean more cases than expected. Because you test many cells at once, a Bonferroni-adjusted cut-off is safer, and this calculator outlines the cells that pass it.
Name the test, then give the statistic with its degrees of freedom and sample size, the p-value and an effect size. For example: χ²(2, N = 320) = 11.67, p = .003, Cramér’s V = .19. Italicize p, N and V, round to two decimals, and write p < .001 for very small values.
Methodology and Sources
How the numbers are computed. Expected counts use the marginal-product formula. The p-value is the regularized upper incomplete gamma function Q(df/2, χ²/2), evaluated with a series expansion or a Lentz continued fraction depending on the argument. Critical values come from numerically inverting that function. The likelihood-ratio statistic G² = 2 Σ O ln(O/E) is shown as a cross-check, because it reaches the same conclusion as Pearson’s χ² whenever expected counts are adequate. We verified the engine against published critical values, including 3.841 (df 1), 5.991 (df 2), 18.307 (df 10) and 10.828 (df 1, α = 0.001), all of which match to three decimals.
References
- Pearson, K. (1900). On the criterion that a given system of deviations from the probable… Philosophical Magazine, 50(302), 157–175. doi:10.1080/14786440009463897
- Yates, F. (1934). Contingency tables involving small numbers and the χ² test. Supplement to the Journal of the Royal Statistical Society, 1(2), 217–235. doi:10.2307/2983604
- Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451. doi:10.2307/3001616
- Sharpe, D. (2015). Your chi-square test is statistically significant: Now what? Practical Assessment, Research, and Evaluation, 20(8). UMass Open Publishing
- Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum Associates.
- Agresti, A. (2018). An Introduction to Categorical Data Analysis (3rd ed.). Wiley.
- Penn State Eberly College of Science. STAT 500, Lesson 8: Chi-Square Test for Independence. online.stat.psu.edu
- NIST/SEMATECH. e-Handbook of Statistical Methods: Chi-Square Goodness-of-Fit Test. itl.nist.gov
Disclaimer: This calculator is an educational and analytical aid. Verify results used in published research, clinical decisions or regulatory submissions with validated statistical software, and consult a qualified statistician where needed.
Manzoor Ahmad
Founder of DexoCalc · 13+ years in web development and SEO
Manzoor builds and personally reviews every DexoCalc calculator. He drew on years of reading clinical and pharmacy research, where chi-square tests and 2 × 2 tables appear on nearly every page, and built this tool to show its working the way a good statistics tutor would. The engine is checked against published critical values before each release.
