Actuarial Statistics · Hypothesis testing and goodness of fit
Chi-Square Goodness of Fit Test: Steps, Degrees of Freedom and Examples
Updated 11 October 2026 · Fact-checked
The chi-square goodness of fit test checks whether observed frequencies match those expected under a stated model. Find expected counts, combine cells with small expected values, compute X² = Σ(O − E)² ÷ E, use degrees of freedom = cells − 1 − parameters estimated, then compare X² with the upper-tail critical value.
Understand Chi-Square Goodness of Fit Test
You have data sorted into categories or ranges. You also have a model, such as a fair die, a Poisson distribution or a normal distribution. The question is whether the data are consistent with that model. The chi-square goodness of fit test answers this.
The idea is simple. Under the model, each cell has an expected frequency E = n × p, where n is the total count and p is the model probability of that cell. You compare E with the observed frequency O. A cell that is far from its expected value gives a large (O − E)². Dividing by E puts big and small cells on the same scale.
Adding these terms gives the statistic X² = Σ (O − E)² ÷ E. If the model is right, X² is approximately chi-square distributed. The approximation is poor when expected frequencies are small. That is why you combine cells until each expected frequency is at least about 5. This is a rule of thumb, not an exact law.
The degrees of freedom depend on how many cells you have and how many parameters you estimated from the same data. Every estimated parameter costs one degree of freedom, because the data were already used to pull the model closer to them. If the model is fully specified in advance, you estimate nothing.
The test is one-sided in practice. A large X² means a poor fit, so you reject H0 only when X² exceeds the upper-tail critical value. A very small X² means the fit is suspiciously good. You can mention this, but it is not the usual conclusion.
Key rules to remember
- Expected frequency
- E = n × p
- n is the total number of observations. p is the probability of the cell under H0. Check that ΣE = ΣO = n.
- Test statistic
- X² = Σ (O − E)² ÷ E
- Sum over all cells after combining. Large values indicate a poor fit.
- Alternative form
- X² = Σ (O² ÷ E) − n
- Useful for quick calculation. It gives the same value if you do not round too early.
- Degrees of freedom
- ν = k − 1 − m
- k is the number of cells after combining. m is the number of parameters estimated from the data. Use m = 0 if the model is fully specified.
- Decision rule
- Reject H0 if X² > χ²(ν) upper critical value at level α
- Equivalently, reject if the p-value P(χ²(ν) > X²) is less than α.
- Cell size rule of thumb
- Combine adjacent cells until E ≥ 5
- A guideline for the chi-square approximation. Combine cells that are adjacent or logically similar, such as tail cells.
How to solve Chi-Square Goodness of Fit Test questions
Use this method for any goodness of fit question, whether the model is a given distribution or one fitted from the data.
- 1State H0 and H1 in words. For example, H0: the data come from a Poisson distribution. H1: they do not.
- 2Find the model probabilities for each cell. If parameters are unknown, estimate them first (usually by maximum likelihood or the sample mean) and note how many you estimated.
- 3Calculate expected frequencies E = n × p. Make sure the last cell is the remaining tail probability so that ΣE = n.
- 4Combine cells with E below 5, usually the tail cells. Add both the observed and expected frequencies of the combined cells. Count the cells k that remain.
- 5Calculate each (O − E)² ÷ E and add them to get X².
- 6Find ν = k − 1 − m. Read the upper-tail critical value from the Tables at the stated level, usually 5%.
- 7Compare and conclude. If X² is larger than the critical value, reject H0. Write the conclusion in the context of the data, such as whether the Poisson model is reasonable for claim counts.
Quickest way: Table-first approach under time pressure
When to use it: Use this when the question gives the observed data and either the model probabilities or a simple model to fit, and you have limited time.
- Draw one table with columns O, p, E and (O − E)² ÷ E before you calculate anything.
- Fill E first and check that it sums to n. This catches probability errors early.
- Combine the small-E cells before you compute the last column, so you do not calculate terms you will discard.
- Write k, m and ν on one line. Then write the critical value and the decision.
- If rounding is a concern, keep E to two decimals. Keep the working visible so you earn method marks even if the arithmetic slips.
Common mistakes in Chi-Square Goodness of Fit Test
Forgetting to subtract degrees of freedom for estimated parameters
Students memorise ν = k − 1 and apply it every time.
Fix: Always ask: did I estimate anything from this data? If yes, subtract one for each parameter. A Poisson with an estimated mean loses one more degree of freedom.
Counting cells before combining
The original table looks complete, so the count of cells is taken from it.
Fix: Combine first. Then count k from the final table. Combining reduces ν.
Combining only the observed frequencies, not the expected ones
Students rush and merge the O column only.
Fix: Add O with O and E with E for the merged cell. Check again that ΣO = ΣE = n.
Using the lower tail or a two-sided critical value
Confusion with z-tests and t-tests.
Fix: For the standard fit test, reject only when X² is above the upper critical value. A large statistic means a poor fit.
Putting the tail probability wrongly, so ΣE ≠ n
The final cell is calculated as P(X = k) instead of P(X ≥ k).
Fix: Make the last cell 1 minus the sum of the earlier probabilities. Then the expected frequencies sum to n.
Stopping at 'reject H0' without context
Students treat the test as only a calculation.
Fix: State what the decision means for the model, such as the data do not support a Poisson model, and name which cells contribute most.
Worked examples
Example 1
A die is rolled 120 times. The results are: 1 appeared 15 times, 2 appeared 25 times, 3 appeared 18 times, 4 appeared 22 times, 5 appeared 20 times, 6 appeared 20 times. Test at the 5% level whether the die is fair. The 5% upper critical value of χ² with 5 degrees of freedom is 11.07.
Show the solution
- H0: the die is fair, so each face has probability 1/6. H1: the die is not fair.
- E = 120 × 1/6 = 20 for each face. ΣE = 120, which matches n.
- All E are at least 5, so no cells need combining. k = 6.
- Terms (O − E)² ÷ E: face 1: (−5)² ÷ 20 = 1.25. Face 2: 5² ÷ 20 = 1.25. Face 3: (−2)² ÷ 20 = 0.20. Face 4: 2² ÷ 20 = 0.20. Faces 5 and 6: 0 each.
- X² = 1.25 + 1.25 + 0.20 + 0.20 = 2.90.
- No parameters were estimated, so ν = 6 − 1 − 0 = 5.
- 2.90 < 11.07, so we do not reject H0.
Answer: X² = 2.90 with 5 degrees of freedom. This is below the 5% critical value of 11.07, so there is no evidence that the die is unfair.
Example 2
A portfolio of 100 policies had the following claim counts in a year: 0 claims on 36 policies, 1 claim on 36, 2 claims on 21, 3 claims on 6, and 4 claims on 1 policy. No policy had more than 4 claims. Test at the 5% level whether a Poisson distribution fits, with the mean estimated from the data. The 5% upper critical value of χ² with 2 degrees of freedom is 5.991.
Show the solution
- H0: the claim counts follow a Poisson distribution. H1: they do not.
- Total claims = 36×0 + 36×1 + 21×2 + 6×3 + 1×4 = 0 + 36 + 42 + 18 + 4 = 100. The sample mean is 100 ÷ 100 = 1, so λ̂ = 1. One parameter was estimated, so m = 1.
- Poisson(1) probabilities: P(0) = e⁻¹ = 0.3679, P(1) = 0.3679, P(2) = 0.1839, P(3) = 0.0613, P(4 or more) = 1 − 0.9810 = 0.0190.
- Expected frequencies (× 100): 36.79, 36.79, 18.39, 6.13, 1.90.
- Only the '4 or more' cell has E below 5 (E = 1.90). Combine it with the adjacent '3' cell (E = 6.13) to give '3 or more': E = 6.13 + 1.90 = 8.03 and O = 6 + 1 = 7. The cells are now 0, 1, 2 and 3 or more, so k = 4.
- Terms: cell 0: (36 − 36.79)² ÷ 36.79 = 0.0170. Cell 1: 0.0170. Cell 2: (21 − 18.39)² ÷ 18.39 = 6.812 ÷ 18.39 = 0.3704. Cell 3+: (7 − 8.03)² ÷ 8.03 = 1.061 ÷ 8.03 = 0.1321.
- X² = 0.0170 + 0.0170 + 0.3704 + 0.1321 = 0.5365, about 0.54.
- ν = k − 1 − m = 4 − 1 − 1 = 2. Critical value 5.991. Since 0.54 < 5.991, we do not reject H0.
Answer: X² ≈ 0.54 with 2 degrees of freedom, below 5.991. There is no evidence against the Poisson model for these claim counts.
Exam tips
- Show the O, E and (O − E)² ÷ E table in every answer. Marks are given for method, so a clear table protects you from arithmetic slips.
- State clearly which cells you combined and why. Examiners look for the E ≥ 5 reasoning and the correct final k.
- Write the degrees of freedom calculation as k − 1 − m with the numbers inserted, and say what m counts.
- In MCQs, the usual trap is the degrees of freedom. Check whether the question gives the parameter or asks you to estimate it.
- Finish with a conclusion in context and, if asked for comment, name the cells with the largest contributions to X².
Practice questions from Hypothesis testing and goodness of fit
- A sequence of 12 claims is classified as above (A) or below (B) the median: A A B B B A B A A A B B. How many runs does the sequence contain…
- Policy claim counts per year are grouped as 0, 1, 2, 3 or more, with observed numbers 60, 30, 8, 2 from 100 policies. The model fitted (para…
- A Poisson distribution is fitted to claim counts per policy by estimating the mean from the data. After grouping the counts into the categor…
- A Poisson distribution is fitted to claim counts by estimating its mean from the data. After grouping, there are 6 cells, each with expected…
- A test of whether claim sizes follow a fitted distribution produces expected frequencies of 30.0, 25.0, 18.0, 4.0 and 3.0 for five classes. …
Chi-Square Goodness of Fit Test in other exams
The same ground in other exams, if you are preparing for more than one or want another angle on it.
Chi-Square Goodness of Fit Test: frequently asked questions
Why do we combine cells with expected frequency less than 5?
The chi-square distribution is only an approximation to the true distribution of X². The approximation is poor when expected frequencies are small, and tiny E values can inflate the terms. Combining cells until E is about 5 or more makes the approximation reasonable. It is a rule of thumb, so follow the threshold the question gives.
How many degrees of freedom does a chi-square goodness of fit test have?
Use ν = k − 1 − m. Here k is the number of cells after combining, and m is the number of parameters estimated from the data. If the distribution is fully specified, m = 0.
What does a large chi-square value mean?
It means the observed frequencies are far from what the model predicts. If X² exceeds the upper-tail critical value for your degrees of freedom and level, you reject H0 and conclude the model does not fit well.
Do I estimate parameters before or after combining cells?
In the usual exam approach you estimate parameters first, from the original data, then calculate expected frequencies and combine cells. The degrees of freedom still use the number of cells after combining and the number of parameters estimated.