Chapter 12: Inferences on Categorical Data

Textbook: Interactive Statistics, 3rd ed. (Sullivan & Woodbury), Sections 12.1–12.2

Chapter Summary

Everything so far has dealt with numerical data — means, proportions, differences. This chapter handles categorical data: counts of things falling into categories. Does a die land on each face equally often? Is party affiliation related to opinion on an issue? The tool for both questions is the chi-square (χ²) distribution, and the test statistic always has the same memorable form: χ² = Σ[(Observed − Expected)² ÷ Expected] — you compare what you saw against what you’d expect under the null hypothesis, square the gaps, scale them, and add up.

There are two main tests. The goodness-of-fit test asks whether one categorical variable follows a claimed distribution (e.g., “accidents are equally likely on each weekday” — expected counts are just total ÷ 7). The test of independence asks whether two categorical variables are related, using a contingency table; here the expected count in each cell is (row total × column total) ÷ grand total, which is what independence would predict. A big χ² (tiny P-value) means the data don’t fit the claim. Realistic example: a store surveys 300 customers on preferred shopping day; if days were equally popular we’d expect about 43 per day, but Saturday shows 78 and Monday 22 — the goodness-of-fit test gives χ² ≈ 41 with 6 df, P-value near zero, so the “equal popularity” claim is rejected. One caution: chi-square tells you that variables are related, never how or why — and it needs actual counts, not percentages.

Study Guide

Key terms and definitions

  • Goodness-of-fit test — tests whether a single categorical variable follows a specified distribution. H₀: the variable follows the claimed distribution.
  • Test of independence — tests whether two categorical variables are independent (unrelated). H₀: the variables are independent.
  • Contingency table — a table of observed counts with rows for one variable and columns for the other.
  • Expected count — the count a cell would have if H₀ were true.
  • Chi-square distribution — right-skewed, nonnegative; shape depends on degrees of freedom. Critical values are always in the right tail.
  • Requirement: all expected counts ≥ 5 (some texts allow a small fraction below 5, but aim for this).

Essential formulas

  • Chi-square test statistic (both tests): χ²₀ = Σ[(O − E)² ÷ E], summing over all categories or cells.
  • Goodness of fit: E_i = n · p_i (total × claimed proportion); df = k − 1, where k = number of categories.
  • Independence: E = (row total × column total) ÷ (grand total); df = (r − 1)(c − 1), where r, c = numbers of rows and columns.
  • P-value: area to the right of χ²₀ under the χ² curve with the appropriate df. Reject H₀ if P-value ≤ α.

Step-by-step procedures

  • Goodness-of-fit test: (1) state the claimed distribution as H₀; (2) compute expected counts E_i = n·p_i; (3) check all E_i ≥ 5; (4) compute χ²₀ = Σ[(O−E)²/E]; (5) df = k − 1; find the P-value (right tail); (6) conclude in context.
  • Test of independence: (1) H₀: the two variables are independent; (2) compute each cell’s expected count = (row total × col total) ÷ grand total; (3) check all ≥ 5; (4) compute χ²₀; (5) df = (r−1)(c−1); P-value from the right tail; (6) conclude.
  • Sanity check: expected counts must sum to the same grand total as the observed counts — if they don’t, recompute.

Common mistakes to avoid

  • Entering percentages or rates instead of counts — chi-square needs raw frequencies.
  • Using the wrong df: goodness-of-fit uses k − 1; independence uses (r − 1)(c − 1).
  • Looking up a two-tailed P-value — chi-square tests are always right-tailed.
  • Claiming the test shows causation or the direction of a relationship — it only detects association.

Self-check: I can…

  • [ ] Set up hypotheses for goodness-of-fit and independence tests.
  • [ ] Compute expected counts for both tests.
  • [ ] Compute the chi-square test statistic and the correct degrees of freedom.
  • [ ] Find the P-value (right tail) and state a contextual conclusion.
  • [ ] Verify the expected-count requirement.

StatCrunch How-To

  • Goodness of fit: Stat > Goodness-of-Fit > Chi-Square Test — enter the observed counts column and the expected counts column (or expected proportions); Compute gives χ²₀, df, and the P-value.
  • Independence (contingency table): Stat > Tables > Contingency > With Summary — enter the table of observed counts row by row (no totals); under “Hypothesis test” options check the chi-square test > Compute. StatCrunch shows expected counts and the test results.
  • With raw data: Stat > Tables > Contingency > With Data — select the row and column variables; same chi-square output.

StatCrunch Video Tutorials

Select a video from the dropdown menu to watch it right here on this page.