Statistics › Section K · The chi-square distribution › Topic K.2
Goodness-of-fit test
Is the die fair? Do subscribers spread across plans the way the company claims? Do Mendel's peas follow the 9:3:3:1 ratio? The goodness-of-fit test asks whether one categorical variable's observed counts fit a claimed distribution - and the chi-square family prices the answer.
Does the data fit the claim?
A single categorical variable, one claimed distribution: that is the goodness-of-fit setting. A casino claims its die is fair; a streamer claims subscribers split 10%, 20%, 40%, 30% across four plans; a geneticist predicts four pea seed types (shape and colour) in a 9:3:3:1 ratio. The test asks whether the observed counts depart from the claimed proportions by more than chance would plausibly produce - and the chi-square statistic from the previous topic measures exactly that departure.
Expected counts from the claim
The null hypothesis hands over the expected counts directly: each category's expectation is the sample total times the claimed proportion,
A claimed 40% share among \(n = 200\) subscribers expects \(0.40 \times 200 = 80\) in that tier. Expected counts need not be whole numbers - 312.75 expected round-yellow peas is perfectly fine arithmetic. The claim supplies the proportions; the sample size supplies the scale; together they set every \(E\).
The statistic and its df
The test statistic is the previous topic's formula, summed over the \(k\) categories:
and the degrees of freedom are \(k - 1\). Why minus one? The observed counts must total \(n\), and the claimed proportions must total 1 - so once \(k - 1\) counts are known, the last is forced. Only \(k - 1\) counts are free to wander, and the df counts freedom, not categories. A big \(\chi^2\) says the departures are collectively too large for chance; the right tail of the \(\text{df} = k-1\) curve prices it.
Conditions: expected counts large enough
Two conditions license the test. The data are a random sample - counts grabbed from a convenience corner prove nothing about the claimed distribution. And each expected count reaches at least about 5: the chi-square approximation misbehaves when a category expects only one or two observations, because a single odd count then dominates the statistic. Categories with thin expectations should be merged with neighbours where that makes sense, or the study enlarged - not tested on hope. The condition is checked on the EXPECTED counts, not the observed ones: the approximation's behaviour depends on the claim's pattern, not the data's.
Worked example: the streamer's claim
A service claims plan shares of 10%, 20%, 40%, 30%. A random sample of \(n = 200\) subscribers shows observed counts 30, 50, 70, 50. 1. Expected: \(20, 40, 80, 60\) - all at least 5. 2. \(\chi^2 = \frac{100}{20} + \frac{100}{40} + \frac{100}{80} + \frac{100}{60} = 5 + 2.5 + 1.25 + 1.67 \approx 10.4\) with df = 3. 3. The df = 3 curve has mean 3 and SD \(\sqrt{6} \approx 2.45\): 10.4 sits about 3 SDs above centre. 4. Software gives \(p \approx 0.015 \le 0.05\): reject - convincing evidence the plan shares differ from the claim, with tiers 1 and 2 over-filled and tiers 3 and 4 under-filled.
Worked example: Mendel's peas
Mendel's cross of two traits, seed shape and colour, predicted four seed types in a 9:3:3:1 ratio; his 556 seeds came out 315, 108, 101, 32. 1. Expected: \(\frac{9}{16} \times 556 \approx 312.75\), \(\frac{3}{16} \times 556 \approx 104.25\), \(\frac{3}{16} \times 556 \approx 104.25\), \(\frac{1}{16} \times 556 \approx 34.75\). 2. \(\chi^2 \approx \frac{(2.25)^2}{312.75} + \frac{(3.75)^2}{104.25} + \frac{(3.25)^2}{104.25} + \frac{(2.75)^2}{34.75} \approx 0.47\) with df = 3. 3. \(p \approx 0.93\): the data hug the prediction astonishingly well - if the 9:3:3:1 model is true, chance alone produces a departure at least this large about 93% of the time. Check: small statistic, enormous p-value, one verdict: consistent. (Historians have noted Mendel's data fit suspiciously well - a goodness-of-fit test raised that question.)
The right tail only
Goodness-of-fit tests read one tail: the right one. A large \(\chi^2\) - departures collectively too big - is evidence AGAINST the claimed distribution. A small \(\chi^2\) is not evidence FOR it, only consistency: the data could fit many distributions, and "not rejected" certifies none of them. Asymmetric logic deserves asymmetric language: the test detects bad fits, it does not certify good ones - which is why Mendel's suspiciously perfect fit is discussed as a curiosity, not celebrated as proof.
Common mistakes to avoid
First, computing expected counts from the OBSERVED proportions - the claim sets the \(E\)'s; using the data's own shares tests nothing. Second, wrong df: it is categories minus one, not the sample size minus one. Third, running the test with expected counts below 5 - merge thin categories or gather more data. Fourth, using percentages instead of counts in the formula: \(\chi^2\) is built from counts, and the same shares at different \(n\) give different statistics. Fifth, quoting a small p-value without saying which categories depart - the residuals tell the story the sum hides. Sixth, reading a large p-value as validation.
Key takeaways
Goodness-of-fit tests one categorical variable against a claimed distribution: expected counts \(E_i = n p_i\), statistic \(\chi^2 = \sum (O-E)^2/E\) on \(k - 1\) degrees of freedom, right tail only, large values arguing against the fit. Conditions: a random sample and expected counts of at least about 5. The streamer's claim: \(\chi^2 \approx 10.4\) at df 3, \(p \approx 0.015\) - reject; the shares differ. Mendel's peas: \(\chi^2 \approx 0.47\), \(p \approx 0.93\) - astonishingly consistent. The test detects misfit; it never certifies a fit, and the residuals name where the misfit lives.
Flashcards
Flashcard
Expected count: sample size times claimed share
Test your understanding
Question 1 of 5
A claimed share is 0.40 and n = 200. What is the expected count for that category?
Question 2 of 5
Observed 30, 50, 70, 50 against expected 20, 40, 80, 60. The chi-square statistic is about:
Question 3 of 5
A goodness-of-fit test has 4 categories. The degrees of freedom are:
Question 4 of 5
The streamer's test gives χ² ≈ 10.4 at df = 3, p ≈ 0.015. At α = 0.05:
Question 5 of 5
A goodness-of-fit test gives a large p-value. The correct reading:
