STATISTICAL METHODS · BEGINNER GUIDE
Chi-Square Goodness-of-Fit: A Simple Example
Compare observed category counts with expected proportions using a goodness-of-fit test.
Quick answer: A chi-square goodness-of-fit test compares observed counts in categories with counts expected under a specified probability model. It asks whether the discrepancies are larger than expected by chance under that model.
What this method answers
The Pearson statistic sums (observed−expected)²/expected across categories. Expected counts come from the null proportions and total sample size; categories should be mutually exclusive and observations independent for the standard setup.
Use it when expected proportions are specified in advance, such as an equal-category model or a documented theoretical distribution. If parameters are estimated from the same data, degrees of freedom may need adjustment.
Before running a calculation, write down the population and the exact quantity you want to estimate. A method name alone does not define the question, the comparison or the assumptions.
Steps to follow
- Specify the category probabilities under the null before examining results.
- Multiply each probability by total n to obtain expected counts.
- Sum squared observed-minus-expected differences divided by expected counts.
- Use the correct degrees of freedom and investigate category-level residuals if needed.
Keep a record of exclusions, recoding decisions and software settings. That makes the analysis easier to check and repeat.
Worked example
A fair six-sided die is rolled 60 times. The equal-probability null expects 10 of each face; observed counts are 8, 12, 9, 11, 10 and 10.
| Face | Observed | Expected |
|---|---|---|
| 1 | 8 | 10 |
| 2 | 12 | 10 |
| 3 | 9 | 10 |
| 4 | 11 | 10 |
| 5 | 10 | 10 |
| 6 | 10 | 10 |
χ² = 4/10 + 4/10 + 1/10 + 1/10 + 0 + 0 = 1.0. With six fixed categories and no fitted parameters, df=6−1=5. The test probability is then obtained from the chi-square reference distribution.
Interpret the result carefully
The observed counts are close to the equal-count expectation in this toy sample. The test does not prove the die is fair; it says this sample is not strongly inconsistent with that null under the assumptions.
Limit to keep in mind: Repeated rolls must be independent and the expected counts should support the chi-square approximation. A small p-value identifies overall mismatch, not which category or mechanism caused it.
When reporting an analysis, include the sample size, estimate, units and uncertainty. Explain why the method fits the sampling and measurement design. Separate planned tests from exploratory checks, and avoid saying that association proves a cause.
Frequently asked questions
What is the null hypothesis?
The category probabilities match the specified expected proportions.
How many degrees of freedom?
Usually categories−1 minus any parameters estimated from the data, under the model setup.
Does a significant result show which category differs?
No. It is an overall test; follow-up inspection needs a planned method and multiplicity care.
Can expected counts be fractional?
Yes. Expected counts are model quantities and need not be whole numbers.