Build expected frequencies, calculate the statistic and adjust degrees of freedom.
Notes and key methods
Under a goodness-of-fit null model, expected frequencies are \(E_i=np_i\). The statistic is \(\displaystyle \chi^{2}= \sum \frac{(O_{i}- E_{i})^{2}}{E_{i}}\).
After combining categories so every expected frequency is at least 5, use k−1−m degrees of freedom, where k is the number of retained categories and m is the number of parameters estimated from these same data. The p-value is an upper chi-squared tail.
Check the conditions
Categories cover the whole outcome space and do not overlap.
Combine sparse expected categories before calculating the final degrees of freedom.
Three worked examples
Example 1 · Chi-squared goodness of fit
A null model assigns equal probabilities to four outcomes, with no fitted parameters. Observed counts are \(30,18,36,12\).
Use a 5% significance level for a written conclusion. A distribution calculator may be used for numerical p-values.
Find the expected frequency in each category.
Find the chi-squared statistic.
Find the p-value.
For a separate fit with \(\displaystyle k=5\) retained classes and one estimated parameter, find the degrees of freedom.
Show the reasoning
(a)
\(\displaystyle E= \frac{96}{4}= 24\)
Answer: \(24\).
(b)
\(\displaystyle \sum \frac{(O- E)^{2}}{E}= 15\)
Answer: \(15\).
(c)
\(P(\chi^2_3\ge 15)=0.00181664896657232\)
Answer: \(0.00181664896657232\).
(d)
\(k-1-1=3\)
Answer: \(3\).
The p-value is \(0.00181664896657232\). Since it is at most 0.05, reject \(\displaystyle H_{0}\): there is evidence that the specified categorical distribution does not fit. This does not give the probability that \(\displaystyle H_{0}\) is true.
Example 2 · Chi-squared goodness of fit
A null model assigns equal probabilities to four outcomes, with no fitted parameters. Observed counts are \(27,23,29,21\).
Use a 5% significance level for a written conclusion. A distribution calculator may be used for numerical p-values.
Find the expected frequency in each category.
Find the chi-squared statistic.
Find the p-value.
For a separate fit with \(\displaystyle k=6\) retained classes and one estimated parameter, find the degrees of freedom.
The p-value is \(0.659389819711985\). Since it exceeds 0.05, do not reject \(\displaystyle H_{0}\): the sample gives insufficient evidence that the specified categorical distribution does not fit. This does not give the probability that \(\displaystyle H_{0}\) is true.
Example 3 · Chi-squared goodness of fit
A null model assigns equal probabilities to four outcomes, with no fitted parameters. Observed counts are \(29,23,32,20\).
Use a 5% significance level for a written conclusion. A distribution calculator may be used for numerical p-values.
Find the expected frequency in each category.
Find the chi-squared statistic.
Find the p-value.
For a separate fit with \(\displaystyle k=7\) retained classes and one estimated parameter, find the degrees of freedom.
The p-value is \(0.325784820275207\). Since it exceeds 0.05, do not reject \(\displaystyle H_{0}\): the sample gives insufficient evidence that the specified categorical distribution does not fit. This does not give the probability that \(\displaystyle H_{0}\) is true.
Common mistakes
Use expected, not observed, frequency in the denominator.
Subtract the number of fitted parameters when determining degrees of freedom.