AP Statistics · Topic 3.15 · Unit 3
AP Stats 3.15: Carrying Out a Chi-Square Test
By Jude Wallis · Published
The chi-square statistic is the sum of (observed minus expected) squared divided by expected, over all cells. Degrees of freedom equal (rows minus 1) times (columns minus 1). Find the p-value from the chi-square distribution, then compare it to alpha.
AP Statistics: Unit 3 (topics 3.15). CED topic 3.15 (Carrying Out a Chi-Square Test for Homogeneity or Independence), skills 3.C, 3.E, 4.F, 4.G.
What topic 3.15 covers
Topic 3.15 carries out the chi-square test you set up in topic 3.14. You compute expected counts, the chi-square test statistic, the degrees of freedom, and the p-value, then state a conclusion in context. The same steps apply to both the test for homogeneity and the test for independence, which is why the two tests share one topic. Only the wording of the hypotheses and conclusion changes between them.
Expected counts and the statistic
For each cell of the two-way table, the expected count under the null hypothesis is
The test statistic sums a contribution from every cell:
Each term measures how far an observed count sits from what the null predicts, scaled by the expected count, so cells with small expected counts can contribute large amounts to the total.
Degrees of freedom, p-value, and conclusion
The statistic follows a chi-square distribution with
when the null is true. Find the p-value as the area to the right of your value from a chi-square table or technology, because larger values give stronger evidence against the null. Compare it to : reject if the p-value is at most , otherwise fail to reject. State the conclusion in context with non-definitive language, referencing the population for independence or the populations for homogeneity.
Following up a significant result
A chi-square test only tells you that the observed counts differ from the null model somewhere in the table; it does not say which cells drive the difference. To describe where the association lives, compare the observed and expected counts cell by cell and note which cells have the largest contributions to the chi-square total. Those cells show where one category appears more or less often than the null predicts.
This follow-up turns a yes-or-no test result into a specific statement about the categorical variables in context. On the exam, a full response names the test, verifies the conditions, shows the statistic and degrees of freedom, states the p-value, and links the decision to the significance level, all in the context of the question.
Chi-square test for a 2 by 2 table
Two treatments each have 50 subjects. Treatment A has 30 successes and 20 failures; treatment B has 20 successes and 30 failures. Test for a difference at .
Totals: each row totals 50, each column totals 50, and the table totals 100.
Expected count for every cell: .
Cell contributions: , and the same value 1 for each of the four cells.
Statistic: .
Degrees of freedom: .
p-value: the area to the right of 4 for is about 0.0455.
With and , the p-value is about 0.0455. Since , reject and conclude there is convincing evidence of a difference in success rates between the treatments.
Frequently asked questions
Why square the difference between observed and expected counts?
Squaring makes every difference positive so overshoots and undershoots both add to the statistic instead of canceling. Dividing by the expected count then scales each term, so a gap counts more when fewer observations were expected.