The chi-square goodness of fit test tells you whether the counts you observed in one categorical variable match the proportions you expected. Did customers pick the four menu items equally often? Do the blood groups in your sample match the national figures? Does a genetics cross follow the 9:3:3:1 ratio? These are all goodness of fit questions.
- Use it for one categorical variable compared against expected proportions.
- χ² = Σ (O − E)² / E, with degrees of freedom = number of categories − 1.
- Every expected count should be at least 5. If not, merge categories or use an exact test.
- Report χ²(df, N = n) = value, p = value, and an effect size such as Cohen’s w.
In this guide
When to use the goodness of fit test
Use it when you have one categorical variable, each person or item falls into exactly one category, and you have a set of expected proportions to test against. The expected proportions can be:
- Equal: every category is expected to be equally common (for example, four product colours).
- Specified by theory or earlier data: a genetic ratio, census percentages, last year’s market shares.
If you have two categorical variables and want to know whether they are related, you need the chi-square test of independence instead. That is the most common mix-up with this test.
Hypotheses
- H₀: the population proportions are equal to the expected proportions.
- H₁: at least one proportion differs from what was expected.
A significant result tells you the distribution does not fit. It does not tell you which category is responsible, so you look at the residuals afterwards (see below).
The formula
For each category, compare the observed count (O) with the expected count (E):
χ² = Σ (O − E)² / E
The expected count is the total sample size multiplied by the expected proportion: E = N × p. The degrees of freedom are k − 1, where k is the number of categories. You compare the result with the chi-square distribution, or look up the critical value in a chi-square table.
Assumptions
- Independent observations. Each observation is counted once, in one category.
- Counts, not percentages or means. Enter the raw frequencies.
- Expected counts of at least 5 in every category (a common rule is that no more than 20% of cells fall below 5 and none below 1). With small expected counts, merge categories that make sense together or use an exact multinomial test.
Worked example 1: equal expected proportions
A café owner wants to know whether customers prefer some of four new drinks. Over one week, 120 customers each choose one drink. If there were no preference, each drink would be chosen 120 / 4 = 30 times.
| Drink | Observed (O) | Expected (E) | (O − E)² / E | Standardized residual |
|---|---|---|---|---|
| Mango cooler | 42 | 30 | 4.80 | 2.19 |
| Iced latte | 28 | 30 | 0.13 | −0.37 |
| Mint lemonade | 30 | 30 | 0.00 | 0.00 |
| Hibiscus tea | 20 | 30 | 3.33 | −1.83 |
| Total | 120 | 120 | 8.27 |
χ² = 8.27 with df = 4 − 1 = 3. The critical value at α = .05 is 7.81, so the result is significant: χ²(3, N = 120) = 8.27, p = .041.
The standardized residuals, (O − E) / √E, show where the misfit comes from. Values beyond about ±1.96 are notable. Mango cooler (2.19) was chosen more often than expected; Hibiscus tea (−1.83) was chosen less often, though it does not quite pass the ±1.96 line.
Worked example 2: unequal expected proportions
A plant genetics student crosses two pea plants and expects the classic 9:3:3:1 ratio. Out of 160 offspring she counts 98, 27, 25 and 10. The expected counts are 160 × 9/16 = 90, then 30, 30 and 10.
| Phenotype | Observed | Expected |
|---|---|---|
| Round, yellow | 98 | 90 |
| Round, green | 27 | 30 |
| Wrinkled, yellow | 25 | 30 |
| Wrinkled, green | 10 | 10 |
χ²(3, N = 160) = 1.84, p = .605. The data are consistent with the 9:3:3:1 ratio. Note the wording: a non-significant goodness of fit test does not prove the theory is right. It only means the data give no reason to reject it.
Paste your data with one row per observation, choose the categorical variable and leave “Expected proportions” blank to test equal proportions. For a theory-based ratio, type the expected proportions in the order of your categories (for example 9, 3, 3, 1). The tool shows observed and expected counts, residuals, χ², df, p and a ready-made APA sentence.
Effect size: Cohen’s w
A p-value depends heavily on sample size. With thousands of observations, tiny deviations become significant. Report an effect size so readers can judge how big the misfit is. The usual choice is Cohen’s w:
w = √(χ² / N)
For the café example, w = √(8.27 / 120) = 0.26. Cohen’s benchmarks are 0.10 small, 0.30 medium and 0.50 large, so this is a small to medium preference. Read more in our guide to effect sizes.
How to report it in APA 7
A chi-square goodness of fit test was conducted to examine whether customers chose the four drinks equally often. Drink choice differed significantly from equal proportions, χ²(3, N = 120) = 8.27, p = .041, w = 0.26. Mango cooler was chosen more often than expected (42 vs. 30; standardized residual = 2.19), whereas Hibiscus tea was chosen less often (20 vs. 30; standardized residual = −1.83).
Include a table of observed and expected counts when you have more than three or four categories. Our APA reporting guide has more examples.
Common mistakes
- Using percentages instead of counts. χ² is calculated from frequencies. Percentages give the wrong answer.
- Testing two variables with the goodness of fit test. If your data form a cross-tab (rows × columns), use the test of independence.
- Ignoring small expected counts. The chi-square approximation becomes unreliable. Merge categories or use an exact test.
- Choosing the expected proportions after looking at the data. The expected values must come from theory, earlier data or a fair “no preference” model, decided in advance.
What is the difference between goodness of fit and test of independence?
The goodness of fit test uses one categorical variable and compares it to expected proportions you specify. The test of independence uses two categorical variables and asks whether they are associated; its expected counts come from the row and column totals.
How many degrees of freedom does a chi-square goodness of fit test have?
The number of categories minus one (k − 1). If you estimated parameters from the data to create the expected values (for example, fitting a Poisson mean), subtract one more degree of freedom for each estimated parameter.
What if my expected counts are less than 5?
Combine neighbouring or similar categories so every expected count reaches 5, or use an exact multinomial test. Do not simply drop the small categories.
Can I use the goodness of fit test to check normality?
You can bin continuous data and compare it with normal-distribution expected counts, but the result depends on how you choose the bins. For normality, the Shapiro-Wilk test is usually a better choice.


