Chi-Square Goodness of Fit Test#
The Chi-Square Goodness of Fit test tests whether the observed frequency distribution of a categorical variable matches a theoretically expected distribution. It answers the question: Does the observed distribution deviate significantly from the expected one?
When to Use#
Use the Chi-Square Goodness of Fit test when you want to:
- Test whether a frequency distribution matches an expected distribution
- Examine a single categorical variable with multiple categories
- Test whether categories are uniformly distributed or follow a specific distribution
- The sample size is sufficiently large (expected frequencies β₯ 5)
Assumptions#
- Observations are independent of one another
- The variable is categorical (nominal or ordinal)
- All expected frequencies are β₯ 5 (if violated: merge categories or use an exact test)
- Each observation belongs to exactly one category
Formula#
The test statistic is calculated as:
where:
- is the observed frequency of category
- is the expected frequency of category
- is the number of categories
The degrees of freedom are:
Under the assumption of a uniform distribution:
Example#
Practical Example: Fairness of a Die
A player suspects that a die is not fair. They roll the die 120 times and record the results:
| Face | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Observed (O) | 25 | 17 | 15 | 23 | 24 | 16 |
| Expected (E) | 20 | 20 | 20 | 20 | 20 | 20 |
For a fair die, each face is expected equally often: .
With df = 5, p = 0.416 (not significant). There is no evidence that the die is unfair.
Effect Size#
Cohen's w as a measure of effect size:
Alternatively:
| Effect Size | Cohen's w |
|---|---|
| Small | 0.10 |
| Medium | 0.30 |
| Large | 0.50 |
Note: The Chi-Square Goodness of Fit test is sensitive to sample size. With very large samples, even small, practically insignificant deviations can become statistically significant. Therefore, the effect size should always be reported.
Further Reading
- Pearson, K. (1900). On the criterion that a given system of deviations from the probable in the case of a correlated system of variables is such that it can be reasonably supposed to have arisen from random sampling. Philosophical Magazine, 50(302), 157β175.
- Agresti, A. (2007). An Introduction to Categorical Data Analysis (2nd ed.). Wiley.