Setting Up a Goodness-of-Fit Test
| English | Chinese | Pinyin |
|---|---|---|
| expected count | 期望频数 | qī wàng pín shuò |
The goodness-of-fit hypotheses
- A goodness-of-fit test checks one variable against a claimed distribution.
- Null $H_0$: the claimed distribution is correct (e.g. all proportions as stated).
- Alternative $H_a$: the distribution is not as claimed (at least one proportion differs).
- $H_a$ is a single "something's off" statement — not a direction.
Expected counts
- The expected count 期望频数 for a category = $n \times$ (its claimed proportion).
- For $100$ candies at $25\%$ each: expected $= 100 \times 0.25 = 25$ per color.
- Expected counts need not be whole numbers — keep them exact.
- They're what the null model predicts, on average.
Check the conditions
- Random: the data come from a random sample or randomized process.
- 10%: $n \le 0.10N$ if sampling without replacement.
- Large counts: every expected count $\ge 5$ (this is the chi-square version).
- All expected counts must clear $5$, or the $\chi^2$ model is unreliable.
Degrees of freedom
- For goodness-of-fit, $df = (\text{number of categories}) - 1$.
- Four candy colors → $df = 4 - 1 = 3$.
- The $df$ picks which chi-square curve to use for the p-value.
- It depends on categories, not on the sample size.
The large-counts condition for chi-square is "every EXPECTED count $\ge 5$," not observed. Check the expected counts, and check them all — one small expected count invalidates the test. And $df = \text{categories} - 1$ here (a common slip is to use $n-1$, which is for $t$, not chi-square goodness-of-fit).
Test whether a die is fair with $60$ rolls. $H_0$: each face has probability $1/6$.
- Expected count per face: $60 \times \tfrac{1}{6} = 10$ (all $\ge 5$ ✓).
- $df$: $6 - 1 = 5$ (six faces).
- $H_a$: the die is not fair — at least one face's probability differs.
A goodness-of-fit test has $H_0$: the claimed distribution holds, vs. $H_a$: it doesn't. Expected count $= n \times$ (claimed proportion); check random, 10%, and every expected count $\ge 5$. The degrees of freedom are $(\text{categories}) - 1$.
The claimed distribution
Expected counts come from the null distribution's proportions.
A fair die is rolled 60 times. What is the expected count for each face (60 × 1/6)?
60 × 1/6 = 10.
For a goodness-of-fit test with 6 categories, what are the degrees of freedom?
df = categories − 1 = 6 − 1 = 5.
The large counts condition for a chi-square test requires...
All EXPECTED counts must be at least 5.
Expected counts must always be whole numbers.
Keep them exact — they need not be integers.
The alternative hypothesis for a goodness-of-fit test says...
Ha is a non-directional 'the distribution isn't as claimed'.