From the free course AP Statistics on Lykke

3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence

Key concepts: Expected count = row total × column total ÷ table total · χ² = Σ (O − E)²/E summed over every cell · Cell contributions reveal which categories drive the statistic · p-value — upper-tail area of the χ² curve with df = (r−1)(c−1) · The p-value assumes H₀ of no difference or no association is true · Conclusion in context — evidence about the populations, not proof of cause

The chi-square test transforms a multi-cell table of raw counts into a single metric of "statistical surprise." While a simple difference in proportions compares two groups, the chi-square procedure allows us to evaluate complex relationships across multiple populations or multiple…

The chi-square test transforms a multi-cell table of raw counts into a single metric of "statistical surprise." While a simple difference in proportions compares two groups, the chi-square procedure allows us to evaluate complex relationships across multiple populations or multiple categories simultaneously. By comparing what we actually observed to what we would expect to see under a null hypothesis of no difference or no association, we can determine if the patterns in our data are likely due to chance or represent a genuine phenomenon.

Expected Counts: The Baseline of "No Effect"

LO 3.15.A [Skill 3.C]: To carry out the test, we must first establish what the data would look like if the null hypothesis ($H_0$) were true. In both the test for homogeneity and the test for independence, the null hypothesis assumes that the distribution of the categorical variable is the same across all groups or that no relationship exists between the two variables.

EK 3.15.A.1: The expected count for any specific cell in a two-way table is the average count we would see if the proportions were perfectly balanced according to the marginal totals. We calculate this using the formula: $$\text{Expected Count} = \frac{(\text{Row Total}) \times (\text{Column Total})}{\text{Table Total}}$$

Consider a study on whether a new medication affects recovery rates across three different age groups (Young, Middle-aged, Senior). If we have a total of 100 "Recovered" patients and 200 total patients, the overall recovery rate is 50%. If age has no effect (the null hypothesis), we would expect 50% of the patients in each age group to have recovered. The formula above automates this logic for every cell in the table.

Misconception Check: A common error is rounding expected counts to the nearest whole number because "you can't have half a person." However, expected counts are theoretical averages, not actual observations. Always keep at least two decimal places for expected counts to maintain the precision of the chi-square statistic.

The Chi-Square Statistic and P-Value

LO 3.15.A [Skill 3.E]: Once we have the expected counts for every cell, we measure the "distance" between our observed data ($O$) and our expected baseline ($E$). This distance is quantified by the chi-square ($\chi^2$) statistic.

EK 3.15.B.1: The chi-square statistic is the sum of the squared differences between observed and expected counts, each scaled by the expected count: $$\chi^2 = \sum \frac{(O - E)^2}{E}$$ This formula ensures that larger deviations contribute more to the statistic, and by dividing by $E$, we ensure that a difference of 5 units matters more when we expect 10 than when we expect 1,000.

The resulting $\chi^2$ value is then used to find the p-value using a chi-square distribution with degrees of freedom $df = (\text{rows} - 1)(\text{columns} - 1)$. The p-value represents the probability of observing a chi-square statistic as large as or larger than the one calculated, assuming the null hypothesis is true.

Interpreting and Justifying Conclusions

[Skill 4.F, 4.G]: The final stage of the procedure is the transition from calculation to claim. We compare the p-value to a pre-specified significance level ($\alpha$), typically 0.05.

  • If p-value $\leq \alpha$: We reject $H_0$. There is convincing statistical evidence of a difference in distributions (homogeneity) or an association between variables (independence).
  • If p-value $> \alpha$: We fail to reject $H_0$. There is not enough evidence to conclude that a difference or association exists.

When justifying a claim, you must state the conclusion in context. For a test of independence, a conclusion might look like: "Because the p-value (0.024) is less than $\alpha = 0.05$, we reject the null hypothesis. There is convincing evidence of an association between exercise frequency and sleep quality for adults in this city." Note the use of non-definitive language ("evidence of") rather than claiming the association is "proven."

Interpretation Check

In a $3 \times 4$ two-way table, a researcher calculates a chi-square statistic of $\chi^2 = 12.5$.

  1. Calculate the degrees of freedom for this test.
  2. If the p-value is 0.051 and $\alpha = 0.05$, what is the appropriate conclusion in terms of the null hypothesis?

Check your reasoning:

  1. $df = (3-1)(4-1) = 2 \times 3 = 6$.
  2. Since $0.051 > 0.05$, we fail to reject the null hypothesis. We do not have convincing evidence of a relationship/difference.
3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence - AP Statistics - image 1
3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence - AP Statistics - image 1
3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence - AP Statistics - diagram 1
3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence - AP Statistics - diagram 1

Source Materials

The whole course on Lykke · Browse all public course wikis