Topic 6 · Lesson 1 of 3
Goodness of fit tests
The test statistic
For each class (cell), compare the observed frequency with the expected frequency predicted by the model. The statistic
is zero when the data match the model exactly and grows as they disagree. Dividing by scales each difference: being 5 out when you expected 10 matters more than being 5 out when you expected 100. A useful equivalent form for calculation is , where is the total frequency.
If the model is right, approximately follows a distribution with degrees of freedom. The distributions are skewed to the right, with mean ; the critical value is the value exceeded with probability . For example and . The test is always one-tailed: only large values of are evidence against the model.
Degrees of freedom
The is because the expected frequencies are made to add up to the observed total. Each parameter you estimate from the data (such as for a Poisson model, or for a binomial or geometric one) makes the model fit more closely and costs another degree of freedom. If the parameter is given in the question, nothing extra is subtracted.
Small expected frequencies
The approximation is poor when expected frequencies are small. Combine any class with with a neighbouring class (usually the tail classes), add their observed frequencies too, and count the classes after combining.
The steps
- : the model fits (name it, with parameters if given); : it does not.
- If needed, estimate the parameter from the data.
- Find the expected frequencies: total probability. Make the last class " or more" so the expected frequencies add up to the total.
- Combine classes with .
- Calculate , find and the critical value.
- If critical value, reject ; conclude in context.
Worked example
A fair dice
A dice is rolled 120 times, giving 14, 25, 19, 23, 17, 22 for the scores 1 to 6. If it is fair, every expected frequency is 20.
Show solutionHide solution
There are 6 classes and no parameters estimated, so and . Since , there is no evidence at the 5% level that the dice is unfair.
The same method tests any given ratio: a theory predicting the ratio for 200 offspring gives expected frequencies 50, 100, 50.
Worked example
A Poisson model with estimated mean
The numbers of typing errors on 100 pages were 0 errors: 27 pages, 1: 43, 2: 19, 3: 6, 4: 4, 5: 1.
Show solutionHide solution
- Mean , so try .
- Expected frequencies: , , , and "3 or more" . (Separately, 3 errors would be 8.67 and "4 or more" 3.38, which is below 5, so these are combined.)
- 4 classes, 1 parameter estimated: , and .
- : do not reject . A Poisson distribution is a suitable model.
Other models
- Binomial : if is not given, estimate it by , and lose one degree of freedom.
- Geometric : estimate by if needed; the last class is " or more", with expected frequency .
- Continuous uniform on with grouped data: the expected frequency of each group is proportional to its width. For 120 arrival times in a 60-minute period, grouped as 0–10, 10–30 and 30–60 minutes, the expected frequencies are 20, 40 and 60.
Try it: choose the χ² test mode, fit a model to data and carry out the goodness of fit test step by step.
Try it: simulation
Poisson, geometric and χ² tests
Loading the simulation…
Practise this topic
Both are part of Premium.