A chi-square goodness-of-fit test checks whether observed categorical counts match a claimed or expected distribution. It is useful when data fall into groups, such as colors, survey choices, genotypes, or weekdays. The test compares what actually happened with what would be expected if the model were true.
Large differences between observed and expected counts provide evidence against the claimed distribution.
The test statistic adds up the squared differences between observed and expected counts, scaled by the expected counts. This makes each category contribute fairly, because a difference of 5 is more surprising when the expected count is 10 than when it is 200. The result is compared to a chi-square distribution with degrees of freedom based on the number of categories.
A small p-value means the observed pattern is unlikely under the claimed model, so the model may not fit the data well.
Key Facts
- Chi-square goodness-of-fit tests one categorical variable against a claimed distribution.
- Test statistic: chi-square = Σ((O - E)^2 / E), where O is observed count and E is expected count.
- Expected count: E = n p, where n is total sample size and p is the claimed category probability.
- Degrees of freedom for a fully specified distribution: df = k - 1, where k is the number of categories.
- Decision rule: reject H0 if p-value < alpha, where alpha is the significance level.
- Common condition: all expected counts should usually be at least 5 for the chi-square approximation to be reliable.
Vocabulary
- Observed count
- The observed count is the actual number of data values that fall in a category.
- Expected count
- The expected count is the number of values predicted for a category if the null hypothesis is true.
- Null hypothesis
- The null hypothesis states that the population distribution matches the claimed probabilities.
- Chi-square statistic
- The chi-square statistic measures the total standardized difference between observed and expected counts.
- P-value
- The p-value is the probability of getting a chi-square statistic at least as large as the observed one if the null hypothesis is true.
Common Mistakes to Avoid
- Using percentages instead of counts in the formula. The chi-square statistic must be calculated from observed and expected counts, not raw percentages.
- Forgetting to compute expected counts with E = n p. Expected counts must use the total sample size and the claimed probability for each category.
- Using df = k instead of df = k - 1. One degree of freedom is lost because the category counts must add to the fixed total sample size.
- Saying a large p-value proves the null hypothesis is true. A large p-value only means there is not enough evidence to reject the claimed distribution.
Practice Questions
- 1 A six-sided die is rolled 120 times, with observed counts 16, 22, 18, 25, 20, and 19. For a fair die, find the expected count for each side and calculate the chi-square statistic.
- 2 A candy company claims four colors occur equally often. In a sample of 200 candies, the observed counts are red 62, blue 45, green 48, and yellow 45. Calculate the expected counts, the chi-square statistic, and the degrees of freedom.
- 3 A chi-square goodness-of-fit test gives p-value = 0.03 at alpha = 0.05. Explain the correct decision and what it means about the claimed distribution.