StatsQuest · Maple Diner · Statistics
Counts and Many Means: Chi-Square and ANOVA
Chi-square compares observed counts to expected counts. ANOVA compares three or more means in one test.
After this guide you can
- Compute expected counts and χ² = Σ(O − E)²/E.
- Run goodness of fit, independence and homogeneity tests with the right df.
- Check conditions: independence and expected counts at least 5.
- Explain SST = SSB + SSW and F = MSB/MSW.
- Know when to follow ANOVA with a post hoc test.
Key terms
- Observed count O
- What you tallied.
- Expected count E
- What H₀ predicts: n × p for fit; (row total × column total)/grand total for tables.
- χ² statistic
- Σ(O − E)²/E; always right tailed.
- Goodness of fit
- One categorical variable against a claimed distribution; df = k − 1.
- Test of independence
- Two variables in one sample; df = (r − 1)(c − 1).
- ANOVA
- Tests H₀: μ₁ = μ₂ = ... = μₖ.
- F statistic
- MSB/MSW: between-group variation over within-group variation.
- Post hoc test
- Tukey or Bonferroni comparisons after a significant F.
The big ideas
- Big gaps between O and E make χ² large; large χ² means small p-value.
- Every expected count should be at least 5; otherwise combine categories or use an exact test.
- Running many t tests inflates the chance of a false positive; ANOVA tests all means at once.
- F near 1 suggests group means differ no more than chance; a large F says at least one mean differs.
- A significant F does not say which means differ; that is the post hoc test's job.
With df = 2 the 5% cutoff is 5.991. An observed χ² of 12 falls far in the tail.
Worth memorizing
| df | χ² critical, α = 0.05 |
|---|
| 1 | 3.841 |
|---|
| 2 | 5.991 |
|---|
| 3 | 7.815 |
|---|
| 4 | 9.488 |
|---|
Worked example
The diner expects orders split 25% breakfast, 25% lunch, 50% dinner. Of 200 orders, 50, 30 and 120 came in. Test at α = 0.05.
- Expected: 50, 50, 100. All are at least 5.
- χ² = (50 − 50)²/50 + (30 − 50)²/50 + (120 − 100)²/100 = 0 + 8 + 4 = 12.
- df = 3 − 1 = 2; critical value 5.991.
- 12 > 5.991 (p ≈ 0.0025), so reject H₀. Lunch contributes most: fewer lunches than expected.
Answer: The order mix differs from the claim
Common mistakes
- Computing χ² with percents instead of counts.
- Using df = n − 1 instead of k − 1.
- Running a χ² test when expected counts are below 5.
- Concluding from ANOVA that every mean differs.
- Running all pairwise t tests without a correction.
Check yourself
- df for a 3 × 4 table?
- Expected count for a cell with row total 60, column total 50, grand total 200?
- O = 30, E = 20. Contribution to χ²?
- Is the χ² test left, right or two tailed?
- Why not run three t tests to compare three diets?
- F = 0.9 with large df. Conclusion?
- SST = 500 and SSB = 200. SSW?
- After a significant F, what next?
Answer key
- 6. (3 − 1)(4 − 1).
- 15. 60 × 50/200.
- 5. 10²/20.
- Right tailed. Only large values are evidence against H₀.
- It inflates the Type I error rate. ANOVA keeps it at α.
- No evidence the means differ. Between and within variation are similar.
- 300. SST = SSB + SSW.
- A post hoc test such as Tukey's HSD. To find which pairs differ.
1 Design2 Describing3 Probability4 Normal5 CLT6 Intervals7 Tests8 Regression10 Health stats11 Full review