← Back to course

Chi-Square Goodness of Fit

You’ll be able to

One categorical variable against a claimed distribution

A chi-square goodness-of-fit (GOF) test checks whether the distribution of a single categorical variable matches a claimed set of proportions — for example, whether a die is fair or whether observed blood types match expected percentages. H₀ states the claimed distribution ("the proportions are as specified"); Hₐ states that at least one proportion differs.

Expected counts and the chi-square statistic

For each category, the expected count is n times the proportion claimed under H₀. The chi-square statistic sums, over all categories, (observed − expected)² / expected. Large discrepancies between observed and expected counts make χ² large, which produces a small p-value (χ² tests are always upper-tailed). The condition is Large Counts: every expected count ≥ 5.

Chi-square statistic and GOF degrees of freedom
χ² = Σ (observed − expected)² / expected · expected = n·p₀ · df = (number of categories) − 1
For goodness of fit, df is the number of categories minus 1. The p-value is the area to the right of χ² under the chi-square distribution.
Worked example

A die is rolled 60 times with counts: 1→8, 2→10, 3→9, 4→12, 5→11, 6→10. Set up the GOF test for a fair die and compute the chi-square statistic.

  1. 1.H₀: the die is fair (each face p = 1/6); Hₐ: at least one proportion differs. Expected count per face = 60·(1/6) = 10 (all ≥ 5).
  2. 2.Compute (O − E)²/E for each face: (8−10)²/10 = 0.4; (10−10)²/10 = 0; (9−10)²/10 = 0.1; (12−10)²/10 = 0.4; (11−10)²/10 = 0.1; (10−10)²/10 = 0.
  3. 3.Sum: χ² = 0.4 + 0 + 0.1 + 0.4 + 0.1 + 0 = 1.0.
  4. 4.df = 6 − 1 = 5; χ² = 1.0 is small, so the p-value is large.
Answer: χ² = 1.0 with df = 5, giving a large p-value (≈ 0.96). There is no convincing evidence the die is unfair — the observed counts are very consistent with a fair die.
Checkpoint

A goodness-of-fit test involves a categorical variable with 5 categories. How many degrees of freedom does the chi-square statistic have?

Watch out

Chi-square procedures use counts, never proportions or percentages. If a problem gives percentages, convert them to observed counts first. The Large Counts condition — every expected count ≥ 5 — is also about counts, and must be checked before trusting the χ² distribution.

Checkpoint

In a chi-square test, one category has observed count 30 and expected count 20. What is this category’s contribution to the chi-square statistic?

Answer the 2 checkpoints as you read.

Sign in to save your progress