Chi-Square Goodness of Fit and Independence
First decide what the counts are testing
Use a goodness-of-fit test when one categorical variable has stated proportions. The null hypothesis H₀ says those proportions describe the population.
Use a test of independence when the same sample records two categorical variables. H₀ says the variables are independent. Organise their joint counts in a two-way table.
For both tests, calculate χ² = Σ (O − E)²/E, where O is the observed count and E is the expected count under H₀. Sum over categories or over body cells, excluding totals. Larger values give more evidence against H₀, so use the upper tail of the chi-square distribution.
Goodness of fit with stated probabilities
Suppose a service expects 30% of independent bookings in the morning, 30% at noon, 20% in the afternoon and 20% in the evening. An independent sample of 60 bookings gives these counts.
| Slot | Morning | Noon | Afternoon | Evening |
|---|---|---|---|---|
| Observed O | 23 | 13 | 12 | 12 |
| Expected E | 18 | 18 | 12 | 12 |
Each E is 60 times its stated probability. Thus χ² = 25/18 + 25/18 + 0 + 0 ≈ 2.78. There are 4 − 1 = 3 degrees of freedom because the total is fixed and the category probabilities were specified in advance. If probabilities are fitted using these same counts, check the degrees of freedom for the fitted model before looking up the cutoff.
At the 5% level the upper critical value for 3 degrees of freedom is about 7.815. Since 2.78 is below 7.815, fail to reject H₀. The sample gives insufficient evidence that the booking proportions differ from the stated proportions.
Independence from a two-way table
For 100 independently selected learners, record the study time and format they prefer. Each learner appears in one body cell.
| Study time | Printed notes | Digital notes | Total |
|---|---|---|---|
| Morning | 28 | 12 | 40 |
| Evening | 22 | 38 | 60 |
| Total | 50 | 50 | 100 |
Under independence, E = row total × column total ÷ grand total. The expected morning-and-printed count is 40 × 50 ÷ 100 = 20. The morning expected counts are 20 and 20, and the evening expected counts are 30 and 30.
Use the four body cells. χ² = 64/20 + 64/20 + 64/30 + 64/30 ≈ 10.67. There are (2 − 1)(2 − 1) = 1 degree of freedom. The 5% critical value is about 3.841. Reject H₀ because 10.67 is above 3.841. In this example the sample supports an association between study time and format preference. The test does not establish that either one causes the other.
Check the conditions
Use counts in mutually exclusive categories and independent observations. For the usual approximation in these exercises, check that every expected count is at least 5. If a table fails that check, choose a method appropriate for sparse counts or combine categories only when that still answers the question. When you fail to reject, report insufficient evidence against H₀.
Quick check. A two-way table has grand total 160. One row totals 64 and one column totals 60. What expected count does their intersection have? If the body has four rows and three columns, what are the degrees of freedom?
Answer. The expected count is 64 × 60 ÷ 160 = 24. The degrees of freedom are (4 − 1)(3 − 1) = 6.
SSC CGL 2026, Statistics syllabus · NIST, chi-square goodness of fit · Penn State, chi-square tests
Sign in to keep your progress. Sign in