Chi-Square Test Calculator

This chi-square calculator runs a goodness-of-fit test or a chi-square test of independence on a contingency table. Enter your observed counts to get the chi-square statistic, expected counts, degrees of freedom, p-value, residuals and an effect size.

Columns separated by commas or spaces.

Checks on your data

  • Expected counts are large enough for the chi-square approximation.
  • Each observation must be counted once and fall in exactly one cell. Percentages or repeated measures on the same people break the test.

Results

Chi-square statistic χ²
9.86364
p-value
0.0072134
Decision at α = 0.05
Reject H₀
Degrees of freedom
2
Critical value (α = 0.05)
5.9915
Cramér’s V (effect size)
0.2654
Sample size N
140
Smallest expected count
15
meets the usual rule of 5
Cells with E < 5
0 %
should be under 20%
χ² distribution, df = 2: shaded = rejection region (α = 0.05)
510χ² = 9.864
Standardised residuals per cell (|value| above 2 is notable)
00.511.5R1C1: 1.85164R1C11.85R1C2: -0.735612R1C2-0.736R1C3: -1.29099R1C3-1.29R2C1: -1.60357R2C1-1.6R2C2: 0.637059R2C20.637R2C3: 1.11803R2C31.12
Expected counts (with standardised residuals in brackets)
Col 1Col 2Col 3
Row 121.43 (1.85)23.57 (-0.736)15 (-1.29)
Row 228.57 (-1.6)31.43 (0.637)20 (1.12)
Show step-by-step solution
  1. Row totals: 60, 80; column totals: 50, 55, 35; grand total 140.
  2. Expected count for each cell = (row total × column total) ÷ grand total.
  3. χ² = Σ (O − E)² ÷ E = 9.86364.
  4. Degrees of freedom = (2 − 1)(3 − 1) = 2.
  5. p-value = P(χ²(2) ≥ 9.8636) = 0.0072134; critical value = 5.9915.
  6. p < α, so we reject H₀.
TestsCounts in categories
Statisticχ² = Σ(O − E)²/E
df (independence)(rows − 1)(cols − 1)
RuleExpected counts ≥ 5

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

  1. Choose independence (a table of counts) or goodness of fit (a single list).
  2. Enter the observed counts. For goodness of fit you may add expected proportions; leave blank for equal expectation.
  3. Select α. Read the p-value and decision.
  4. 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

χ2=∑(Oi−Ei)2Ei\chi^2=\sum\frac{(O_i-E_i)^2}{E_i}

Expected count in a contingency table

Eij=(row i total)(column j total)NE_{ij}=\frac{(\text{row } i \text{ total})(\text{column } j \text{ total})}{N}

Degrees of freedom

dfGOF=k−1,dfind=(r−1)(c−1)df_{GOF}=k-1,\quad df_{ind}=(r-1)(c-1)

Cramér’s V

V=χ2N (min⁡(r,c)−1)V=\sqrt{\frac{\chi^2}{N\,(\min(r,c)-1)}}

Standardised residual

zij=Oij−EijEijz_{ij}=\frac{O_{ij}-E_{ij}}{\sqrt{E_{ij}}}

Chi-Square Test Variables Explained

SymbolMeaningNotes
χ²Chi-square statisticΣ (O − E)² ÷ E
OObserved countFrom your data
EExpected countRow total × column total ÷ N
dfDegrees of freedom(rows − 1)(columns − 1), or categories − 1
VCramér's VEffect size from 0 to 1

Chi-Square Test Worked Example

With the example values loaded in the calculator above, the steps are:

  1. Row totals: 60, 80; column totals: 50, 55, 35; grand total 140.
  2. Expected count for each cell = (row total × column total) ÷ grand total.
  3. χ² = Σ (O − E)² ÷ E = 9.86364.
  4. Degrees of freedom = (2 − 1)(3 − 1) = 2.
  5. p-value = P(χ²(2) ≥ 9.8636) = 0.0072134; critical value = 5.9915.
  6. p < α, so we reject H₀.

Result: Chi-square statistic χ² = 9.86364; p-value = 0.0072134; Decision at α = 0.05 = Reject H₀.

Worked Example: Is a Die Fair?

A die is rolled 60 times. If it is fair, each face is expected 10 times. The observed counts for faces 1 to 6 are 5, 8, 9, 8, 10 and 20. The contributions (O − E)² ÷ E are 2.5, 0.4, 0.1, 0.4, 0 and 10, which add to χ² = 13.4.

There are 6 − 1 = 5 degrees of freedom, and the critical value at α = 0.05 is 11.07. Because 13.4 is larger, and the p-value is 0.0199, you reject the hypothesis that the die is fair. The big contribution comes from the 20 sixes, which is where to look first. The test says the counts are not consistent with equal chances, not which face is to blame, so the cell contributions are the guide.

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.

The chi-square family
TestQuestionData
Goodness of fitDoes one variable match a given distribution?One list of category counts
IndependenceAre two variables associated?One sample, cross-classified in a table
HomogeneityDo 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.

Cramér’s V guidelines (Cohen, by degrees of freedom of the smaller dimension)
min(r, c) − 1SmallMediumLarge
10.100.300.50
20.070.210.35
30.060.170.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

Goodness of fit

Test whether observed counts match a stated distribution.

Independence

Test whether two categorical variables are related using a table of counts.

Effect size

Read Cramér’s V to judge how strong an association is.

Validity check

See the smallest expected count and how many cells fall below 5.

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 category subtract the expected count from the observed count, square it and divide by the expected count. Add the results. Compare the total with the critical value for the degrees of freedom, or find its p-value.

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.

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.

What is the Excel function for a chi-square test?

=CHISQ.TEST(observed_range, expected_range) returns the p-value. =CHISQ.INV.RT(alpha, df) returns the critical value.

Related calculators

Last updated 2026-11-09. See our disclaimer.