Chi-Squared Tests
Comparing Categorical Counts with a Chi-Squared Test
Start with a count-generating null model
A chi-squared test is for counts in categories. The null hypothesis supplies a model for what the category counts should look like if the proposed process holds.
In a goodness-of-fit setting, those expected counts come from stated proportions. In a contingency table, the null model of independence gives each expected cell as (row total × column total) / grand total.
Measure discrepancy cell by cell
For every category, calculate (O − E)2 / E, then add the nonnegative contributions. Squaring prevents positive and negative deviations from cancelling; dividing by E compares deviations on a common relative scale. A rare category can therefore matter greatly even when its raw difference is small.
Degrees of freedom and a conclusion
For a goodness-of-fit test with no fitted parameters, degrees of freedom are the number of categories minus one.
For an r by c independence table, they are (r − 1)(c − 1). A large statistic is evidence against the exact null model, not proof of a particular alternative cause.
Compare the statistic with a stated critical value or use a p-value, and report whether the evidence is sufficient to reject at the selected significance level.
Check the approximation before trusting it
The usual chi-squared reference distribution is an approximation. It relies on independent observations and adequately sized expected counts; if expected counts are sparse, combine scientifically similar categories only when that decision is made without looking for a preferred result, or use a more suitable exact or simulation method.
The test also cannot repair biased sampling: it evaluates the counts under its null model, not whether the sample represents a broader population.
A two-category experiment has observed counts 41 and 59. Under the null hypothesis, the expected counts are 50 and 50. What is the chi-squared statistic?
A goodness-of-fit test has four categories, no parameters estimated from the data, and χ2 = 9.60. At α = 0.05, the critical value for 3 degrees of freedom is 7.815. Which conclusion is supported?