Chi-Square Goodness-of-Fit Test
Test whether observed counts for one categorical variable match a hypothesized distribution. Compute χ² = ∑(O−E)²/E, find the p-value from a chi-square distribution with df = k−1, and interpret the result.
A lesson of AP Statistics, in Inference for Categorical Data: Proportions, about 10 minutes.
By the end of this lesson, you will be able to conduct a chi-square goodness-of-fit test, calculate the chi-square statistic, and interpret results in context.
When to Use the Goodness-of-Fit Test
The chi-square goodness-of-fit test asks: does the observed distribution of a single categorical variable match a hypothesized distribution?
Examples:
- Do M&M colors occur in the proportions the company claims?
- Is the distribution of birth months uniform?
- Does the die appear to be fair?
Setup
Hypotheses:
- H₀: The distribution of the variable matches the hypothesized distribution
- Hₐ: The distribution does not match
Categories: k categories with observed counts O₁, O₂, ..., Oₖ
Expected counts: If H₀ is true, the expected count for category i is:
$$E_i = n \times p_i$$
where n is the total sample size and pᵢ is the hypothesized proportion for category i.
Conditions
1. Random: Data from a random sample.
2. Large counts: Expected count ≥ 5 for ALL categories. If some categories have small expected counts, combine categories.
The Chi-Square Statistic
$$\chi^2 = \sum \frac{(O_i - E_i)^2}{E_i}$$
Logic: If the observed and expected counts are similar, χ² will be small. If they differ substantially, χ² will be large.
Degrees of freedom: df = k - 1 (where k = number of categories)
The p-value is the area to the RIGHT of the calculated χ² in the chi-square distribution with df degrees of freedom.
Note: The chi-square test is always right-tailed — we're testing whether χ² is "too large."
Example
A six-sided die is rolled 120 times. The results are:
| Face | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Observed | 28 | 18 | 15 | 22 |