Chi-square goodness-of-fit test
Tests whether the counts in k categories are consistent with a stated set of proportions.
- Observed count in category i.
- Expected count under H₀.
- Proportion for category i stated by H₀.
- Total count.
- Number of parameters estimated from the data (e.g. 1 for a fitted Poisson mean; 0 when all p_i are given).
When to use
One categorical variable and a hypothesised distribution: is a die fair, do calls spread evenly over weekdays, do counts follow a fitted Poisson model? The p-value is the upper tail of .
Assumptions
- Independent observations, each counted in exactly one category.
- Counts, not percentages or means.
- Expected counts large enough: all is the classic rule (Cochran's: no more than 20% below 5, none below 1). Merge sparse categories or simulate otherwise.
How to interpret
A small p-value says the observed distribution differs from the hypothesised one; look at the contributions or residuals to see where. A large p-value means the data are consistent with the model, not that the model is right.
Common mistakes
- Running the test on percentages (the statistic depends on the counts).
- Forgetting to subtract estimated parameters from the df.
- Checking observed counts instead of expected counts against the "≥ 5" rule.
Example
60 rolls of a die: 8, 12, 9, 15, 10, 6. Each . Contributions 0.4, 0.4, 0.1, 2.5, 0, 1.6, so on 5 df, : no evidence that the die is unfair (60 rolls also have little power to detect a modest bias).