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.
Understanding Statistics: Chi-Square Goodness of Fit
The test starts with a null hypothesis, which is the rule or pattern being checked. For example, a company may claim that each of four package colors is produced in equal amounts. In a sample of 200 packages, the null hypothesis gives 50 as the expected count for every color.
The categories must be separate, so each item goes into one group only. They must cover every possible result, so no item is left out. Good category definitions matter because unclear groups can create differences that come from recording choices rather than from the process being studied.
The calculation treats positive and negative differences in a careful way. If one category has too many items while another has too few, simply adding the differences would give zero. Squaring prevents this cancellation.
Dividing by the expected count gives a scale for judging the difference. Being 10 away from an expectation of 15 is much more notable than being 10 away from an expectation of 500. After finding the overall test result, students should inspect the separate category contributions.
These show which groups caused the disagreement. A global result does not identify one single category by itself, and examining many categories can lead people to overinterpret random variation.
The chi-square reference distribution works because random samples produce many possible patterns of counts. Most random patterns stay fairly close to the expected pattern. Very uneven patterns occur less often if the null hypothesis is true.
The degrees of freedom reflect a built-in restriction. Once the total sample size and all but one category count are known, the final count is fixed. If probabilities are estimated from the same data rather than supplied in advance, more freedom is used up, so the degrees of freedom must be reduced.
Small expected counts are a major warning sign. Combining rare categories can help when the combined group still makes scientific sense. Otherwise, a simulation-based or exact method may be more suitable.
Independence is another important condition. Each counted item should represent a separate observation. Repeated answers from the same person, several products from one faulty machine run, or family members in a genetics study may be related.
Such clustering can make ordinary random differences look stronger than they really are. A small p-value is evidence that the claimed pattern does not describe the data well, not proof that a particular alternative explanation is true. Large samples can flag tiny, unimportant departures, while small samples can miss meaningful ones.
Students should compare observed proportions, use a bar chart, and consider the size and practical meaning of the differences. This habit is useful in quality control, election surveys, genetic inheritance experiments, and checks of whether events occur evenly across days.
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.