Chi-Square Goodness-of-Fit Test: Example and APA 7 Report

In short

The chi-square goodness-of-fit test asks whether the counts of one categorical variable match a distribution you specify in advance, such as the age composition of the population your sample should represent. It needs raw counts (not percentages), independent observations, mutually exclusive and exhaustive categories and large enough expected frequencies, conventionally no expected count below 1 and no more than 20% below 5. The degrees of freedom are the number of categories minus 1 (minus one more for each parameter estimated from the data). In the worked example, a sample of 200 differs from the census age profile: χ2(3, N = 200) = 10.12, p = .018, w = 0.22.

Most chi-square tests in psychology papers are tests of independence: two categorical variables crossed in a contingency table. The goodness-of-fit test is the other one, with a single variable and a reference distribution. It answers questions such as whether your sample's composition matches the population, whether participants chose the four options of a task equally often, or whether the observed frequencies of a behaviour follow a theoretical model. Here is what it tests, what it requires, a fully worked example and the APA 7 sentence.

What the goodness-of-fit test checks, and how it differs from the test of independence

The goodness-of-fit test has one categorical variable with k categories and a set of expected proportions fixed before looking at the data. The null hypothesis is that the population proportions equal those expected proportions. The test of independence has two categorical variables and no external reference: the expected counts come from the table's own margins, and the null hypothesis is that the two variables are unrelated. The formula is the same in both:

χ2 = Σ (O − E)2 / E

summing over cells, where O is the observed count and E the expected count. What changes is where E comes from and, therefore, the degrees of freedom. If you are crossing two variables, you need the chi-square test of independence and its APA 7 report instead.

The expected proportions have to come from outside your data: a census, a previous study, a theory, or equal proportions when the hypothesis is “no preference”. Choosing them after seeing the counts turns the test into a description of your own sample.

Requirements: expected frequencies, independence, exhaustive categories

  • Counts, not percentages. The statistic depends on the sample size, so computing it on percentages gives a number that is wrong for any sample other than exactly 100 people. Always enter frequencies.
  • Independent observations. Each person contributes one observation to one category. Twenty choices from each of ten participants are not 200 independent observations, and treating them as such makes the p value far too small.
  • Mutually exclusive and exhaustive categories. Every observation falls in exactly one category, and the expected proportions add up to 1. A residual “other” category is often what makes the set exhaustive.
  • Large enough expected frequencies. The χ2 distribution is an approximation that works when the expected counts are not too small. The usual guideline, from Cochran (1954), is that no expected count should be below 1 and no more than 20% of them below 5. It concerns the expected counts, not the observed ones: an observed zero is not a problem in itself.

Worked example, step by step

An online survey on wellbeing recruited 200 adults. To see whether the sample's age profile resembles that of the target population, you compare it with census proportions (taken here, for the example, as 30% aged 18–34, 35% aged 35–54, 25% aged 55–74 and 10% aged 75 or older).

Step 1: expected counts. Multiply each proportion by N = 200: 60, 70, 50 and 20. All are well above 5, so the approximation is safe.

Step 2: the contribution of each category.

Table 1
Observed and Expected Frequencies by Age Group
Age group Observed n (%) Expected n (%) (O − E)2/E Std. residual
18–34 78 (39) 60 (30) 5.40 2.32
35–54 70 (35) 70 (35) 0.00 0.00
55–74 36 (18) 50 (25) 3.92 −1.98
75 or older 16 (8) 20 (10) 0.80 −0.89

Note. N = 200. Expected frequencies from census proportions. Std. residual = (O − E)/√E. χ2(3, N = 200) = 10.12, p = .018.

Step 3: the statistic. Add the contributions: 5.40 + 0.00 + 3.92 + 0.80 = 10.12.

Step 4: degrees of freedom and p. With four categories, df = 3. The probability of a χ2 of 10.12 or more with 3 degrees of freedom is .018. The sample's age profile differs from the census.

Step 5: where the difference is. A significant overall test says the profile differs, not where. The standardized residuals in the last column answer that: values beyond about ±2 mark the categories that depart most. The youngest group is over-represented (78 observed against 60 expected) and the 55–74 group under-represented (36 against 50), a pattern often seen with online recruitment. For a stricter cell-by-cell reading, the adjusted residuals divide O − E by √[E(1 − p)] and are referred to the standard normal: 2.78 and −2.29 for those two groups.

Degrees of freedom: k − 1, minus the estimated parameters

With k categories, only k − 1 counts are free, because the last one is fixed by the total. That is why the example has 3 degrees of freedom. The rule changes when the expected proportions are not fully specified in advance but partly estimated from the same data. If you test whether a count variable, such as the number of panic attacks per week, follows a Poisson distribution, and you estimate its mean from your sample, you lose one more degree of freedom for that parameter: df = k − 1 − 1. Each estimated parameter costs one. Forgetting this makes the test too lenient, because the estimated distribution has already been pulled toward your data.

Effect size: Cohen's w

The p value depends on the sample size; the effect size does not. For goodness of fit, the standard index is Cohen's w:

w = √(χ2 / N) = √(10.12 / 200) = 0.22

Equivalently, w = √[Σ (pobserved − pexpected)2 / pexpected], which shows that it measures how far the observed proportions are from the expected ones. Cohen (1988) proposed 0.10, 0.30 and 0.50 as small, medium and large, so 0.22 is between small and medium. Like all of Cohen's benchmarks, they are a last resort when your field gives you nothing better; what matters is whether a 9-point over-representation of young adults is a problem for the conclusions you want to draw.

One formatting detail: unlike a correlation, w can exceed 1 in a goodness-of-fit test when an expected proportion is small, so by APA's rule it keeps the leading zero (w = 0.22). For tables crossing two variables, the usual effect sizes are phi and Cramér's V, covered in how to report phi and Cramér's V in APA 7.

How to report it in APA 7

The sentence carries the degrees of freedom and the sample size in parentheses, the statistic to two decimals, the exact p and the effect size, plus the reference distribution in words: “A chi-square goodness-of-fit test indicated that the age distribution of the sample differed from that of the census population, χ2(3, N = 200) = 10.12, p = .018, w = 0.22. Adults aged 18–34 were over-represented (39% vs. 30%) and adults aged 55–74 under-represented (18% vs. 25%).”

χ is a Greek letter and stays upright; N, p and w are italicized. Including N in the parentheses is what lets a reader recompute w from your statistic, and it is frequently left out; the chi-square without N check shows what is lost. If you want the clicks in software, the chi-square tutorial in JASP walks through the interface; for goodness of fit, the analysis is Frequencies → Multinomial Test, with the expected proportions entered by hand. In SPSS it is Analyze → Nonparametric Tests → Legacy Dialogs → Chi-square, entering the expected values in category order, and in R, chisq.test(c(78, 70, 36, 16), p = c(.30, .35, .25, .10)).

When expected counts are small: the exact multinomial test

With a small sample the χ2 approximation can be poor. Suppose a pilot of 24 participants gives counts of 11, 5, 3 and 5 across the same four age groups. The expected counts are 7.2, 8.4, 6.0 and 2.4: one of four cells (25%) is below 5, which breaks Cochran's guideline. The asymptotic test gives χ2(3, N = 24) = 7.70, p = .053.

The exact multinomial test avoids the approximation by computing, from the multinomial distribution, the probability of every possible way of distributing 24 people across four groups under the null hypothesis. Its p value is the sum of the probabilities of the outcomes at least as extreme as the one observed. “At least as extreme” needs a definition: ordering outcomes by their probability gives p = .049, and ordering them by their χ2 value gives p = .052. In R, the EMT package computes both (multinomial.test, with the useChisq argument choosing the ordering), and chisq.test(..., simulate.p.value = TRUE) gives a Monte Carlo approximation to the second.

The example is deliberately uncomfortable: three reasonable procedures give .049, .052 and .053. The lesson is not that the exact test “rescued” significance. It is that the evidence is the same borderline evidence under any of them, that the procedure must be chosen before seeing the result (by the expected counts, which you can compute before collecting a single response), and that a pilot of 24 cannot settle the question. Merging adjacent categories is the other option, provided the merged categories still make sense and the decision is made from the expected counts, not from the result. For small contingency tables, where two variables are crossed, the equivalent exact approach is Fisher's exact test.

Does your chi-square report N, degrees of freedom and an effect size?

Without them the reader cannot check the statistic or judge the size of the difference, and a reviewer will ask for both.

Run your paper through Previum →

Frequently asked questions

What does a chi-square goodness-of-fit test tell you?

Whether the observed counts of one categorical variable are compatible with a set of expected proportions specified in advance. A significant result means the population proportions probably differ from the expected ones; the standardized residuals show which categories drive the difference, and Cohen's w how large it is.

What are the requirements for a goodness-of-fit test?

Raw counts rather than percentages, independent observations (each person counted once), mutually exclusive and exhaustive categories, expected proportions fixed before seeing the data, and expected counts that are not too small: conventionally none below 1 and no more than 20% below 5.

How do you calculate degrees of freedom for goodness of fit?

The number of categories minus 1. If you estimate parameters of the expected distribution from the same data, such as the mean of a Poisson distribution, subtract one more degree of freedom for each estimated parameter.

What is the difference between goodness of fit and the test of independence?

Goodness of fit has one variable and compares it with an external distribution. The test of independence has two variables crossed in a table and takes its expected counts from the table's own margins; its degrees of freedom are (rows − 1)(columns − 1).

How do you report a chi-square goodness-of-fit test in APA 7?

With the degrees of freedom and sample size in parentheses, the statistic, the exact p and the effect size: χ2(3, N = 200) = 10.12, p = .018, w = 0.22. State the reference distribution in words and describe which categories differ.

The goodness-of-fit test is short to run and easy to report well: counts, expected proportions chosen in advance, the right degrees of freedom, N in the parentheses and an effect size. When the harder question is what a sample that departs from the population means for your conclusions, and whether weighting or a sensitivity analysis is needed, that is what my statistical consulting is for.

References

Cochran, W. G. (1954). Some methods for strengthening the common χ2 tests. Biometrics, 10(4), 417–451. https://doi.org/10.2307/3001616

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.

Cite this guide

Ciudad-Fernández, V. (2026, November 12). Chi-Square Goodness-of-Fit Test: Example and APA 7 Report. Ciudad Science. https://analisisdedatospsicologia.com/en/blog/chi-square-goodness-of-fit-test

Keep reading

All blog articles