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.

✓ R × C contingency tables up to 8 × 8 ✓ Yates correction for 2 × 2 ✓ Adjusted residuals heatmap ✓ P-value from χ² and df

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.

Significance level (α)
Rows
2
Columns
3
Row variable
Column variable
Observed counts

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.

Results update as you type.

Result

Enter your counts

Your verdict appears here.

χ² statistic—
p-value—
df—
p = 10.10.010.00110⁻⁴10⁻⁵≤10⁻⁶
The white dot is your p-value. The teal line is α. A dot to the right of the line means a significant result.

Chi-square distribution

The curve shows where your statistic falls relative to the critical value.

p-value area (right tail beyond your χ²)Critical value at α

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
      Copied ✓

      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.

      1. 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.
      2. Set α. The default of 0.05 suits most coursework and research. Pick 0.01 or 0.001 for stricter claims.
      3. 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.
      4. Read the verdict and the p-value meter. If the white dot sits right of the teal α line, the result is significant.
      5. 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.
      6. 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 − E)² / E
      Expected count E = (row total × column total) / N
      Independence: df = (r − 1)(c − 1)  ·  Goodness of fit: df = k − 1 − m

      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.)

      Cramér’s V = √( χ² / (N × (min(r, c) − 1)) )    w = √( χ² / N )

      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.

      TestQuestion it answersData layoutNull hypothesis (H₀)df
      IndependenceAre two categorical variables related in one population?One sample, cross-classified into an R × C tableThe variables are independent(r − 1)(c − 1)
      HomogeneityDo several populations share the same distribution?Separate samples, one per rowCategory proportions are equal across groups(r − 1)(c − 1)
      Goodness of fitDoes one variable follow a claimed distribution?One row of k category countsObserved proportions match the expected onesk − 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 timeLateNot picked upRow total
      Reminder SMS112 (98)28 (32)20 (30)160
      No reminder84 (98)36 (32)40 (30)160
      Column total1966460N = 320
      1. 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.
      2. 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.
      3. Sum. χ² = 2(2.000 + 0.500 + 3.333) = 11.667.
      4. Degrees of freedom. df = (2 − 1)(3 − 1) = 2. The critical value at α = 0.05 is 5.991.
      5. p-value. The right-tail area beyond 11.667 with 2 df is p ≈ 0.0029, well below 0.05, so you reject H₀.
      6. 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.
      7. 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) − 1SmallMediumLargeExample table
      10.100.300.502 × 2, 2 × 5
      20.070.210.353 × 3, 3 × 4
      30.060.170.294 × 4, 4 × 6
      40.050.150.255 × 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
      12.7063.8415.0246.63510.828
      24.6055.9917.3789.21013.816
      36.2517.8159.34811.34516.266
      47.7799.48811.14313.27718.467
      59.23611.07012.83315.08620.515
      610.64512.59214.44916.81222.458
      712.01714.06716.01318.47524.322
      813.36215.50717.53520.09026.124
      914.68416.91919.02321.66627.877
      1015.98718.30720.48323.20929.588
      1218.54921.02623.33726.21732.909
      1522.30724.99627.48830.57837.697
      2028.41231.41034.17037.56645.315
      2534.38237.65240.64644.31452.620
      3040.25643.77346.97950.89259.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.

      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

      1. 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
      2. 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
      3. Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451. doi:10.2307/3001616
      4. Sharpe, D. (2015). Your chi-square test is statistically significant: Now what? Practical Assessment, Research, and Evaluation, 20(8). UMass Open Publishing
      5. Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum Associates.
      6. Agresti, A. (2018). An Introduction to Categorical Data Analysis (3rd ed.). Wiley.
      7. Penn State Eberly College of Science. STAT 500, Lesson 8: Chi-Square Test for Independence. online.stat.psu.edu
      8. 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, author of DexoCalc

      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.

      Read Manzoor’s story