AP Statistics · Unit 3 · Topic 3.15

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

    Reviewed by P V Satish, Senior Faculty of Science and Academic Consultant · PG Life Sciences, PGD Biotechnology · 20+ years teaching NEET and AP · Special interest in biotechnology, biochemistry and the basics of physics
    Updated

    In short

    The chi-square statistic is χ2=∑(observed−expected)2expected\chi^2 = \sum \frac{(\text{observed} - \text{expected})^2}{\text{expected}}, summed over every cell. Large values mean the observed counts are far from what H₀ predicts. The p-value is the area to the right of χ² under the chi-square curve with (r − 1)(c − 1) degrees of freedom. After a significant result, the largest components show where the biggest departures from H₀ are.

    What you need to know

    • Calculate the chi-square statistic from observed and expected counts.
    • Find the p-value using the chi-square distribution with the correct df.
    • Conclude a homogeneity or independence test in context.
    • Use components to describe where the evidence comes from.

    The chi-square statistic and distribution

    χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}

    Each cell contributes (O − E)²/E, its component. Squaring makes every component positive, so χ² is never negative, and dividing by E puts a difference of 10 from an expected 20 on a bigger scale than a difference of 10 from an expected 200. If H₀ is true, χ² follows (approximately) a chi-square distribution: right-skewed, starting at 0, with mean equal to its degrees of freedom. The p-value is always the upper-tail area.

    Example 1: homogeneity (not significant)

    From topic 3.14: independent random samples of 100 students at School X and School Y; observed counts X: 45, 30, 25 and Y: 30, 40, 30 (flashcards, videos, notes); expected counts 37.5, 35, 27.5 in each row. Conditions were met (smallest expected count 27.5). Use α = 0.05.

    χ2=(45−37.5)237.5+(30−35)235+(25−27.5)227.5+⋯≈1.500+0.714+0.227+1.500+0.714+0.227=4.88\chi^2 = \frac{(45-37.5)^2}{37.5} + \frac{(30-35)^2}{35} + \frac{(25-27.5)^2}{27.5} + \cdots \approx 1.500 + 0.714 + 0.227 + 1.500 + 0.714 + 0.227 = 4.88

    With df = 2, P(χ² ≥ 4.88) ≈ 0.087 (calculator: χ²cdf(4.88, 1E99, 2), or χ²-Test on the matrix of observed counts).

    Conclude. Because 0.087 > 0.05, we fail to reject H₀. There is not convincing evidence that the distribution of preferred revision method differs between all students at School X and all students at School Y. The sample differences (45% vs 30% flashcards) could plausibly be due to sampling variability.

    Example 2: independence (significant)

    One random sample of 300 students at a large school was classified by year and plan. Juniors: 90 university, 30 work, 30 undecided. Seniors: 66 university, 42 work, 42 undecided. Column totals 156, 72, 72; both row totals 150. Expected counts: 78, 36, 36 in each row (all at least 5). H₀: there is no association between year and plan among all students at the school. α = 0.05.

    Components: (90 − 78)²/78 ≈ 1.846, (30 − 36)²/36 = 1.000, (30 − 36)²/36 = 1.000, and the same three again for seniors. So χ² ≈ 7.69 with df = 2, giving p-value ≈ 0.021.

    Conclude. Because 0.021 < 0.05, reject H₀. There is convincing evidence of an association between year and plan after school among all students at the school. The largest components are for university: juniors chose it more often than expected (90 vs 78) and seniors less often (66 vs 78).

    Key terms

    Chi-square statistic χ²
    Σ(observed − expected)²/expected over all cells; measures how far the counts are from H₀.
    Component
    One cell's contribution (O − E)²/E to χ².
    Chi-square distribution
    A right-skewed distribution of non-negative values, determined by its degrees of freedom.
    χ²-Test
    The calculator routine that takes a matrix of observed counts and returns χ², df and the p-value.

    Common mistakes

    • Using a two-tailed p-value.

      Chi-square p-values are always the area to the right of χ².

    • Entering percentages into the matrix.

      Use counts.

    • Concluding 'the variables are independent' after failing to reject.

      Say there is not convincing evidence of an association.

    How this topic is tested

    • Show at least one component calculation and the sum.
    • State df and the p-value together: 'χ² = 4.88, df = 2, p ≈ 0.087'.
    • After a significant result, name the cell with the largest component and say whether observed was above or below expected.

    Practice questions

    Original AP-style multiple-choice questions. Pick an answer to see the explanation.

    1. Question 1 · SP 3 · Analyze Data

      A cell has observed 50 and expected 40. Its contribution to χ² is:

    2. Question 2 · SP 3 · Analyze Data

      For χ² = 7.2 with df = 3, the p-value is about:

    3. Question 3 · SP 4 · Interpret Results

      A test for independence gives p-value 0.30. The best conclusion is:

    4. Question 4 · SP 3 · Analyze Data

      Why is a chi-square p-value always an upper-tail area?

    5. Question 5 · SP 4 · Interpret Results

      After a significant chi-square test, a cell has the largest component, with observed 12 and expected 25. This means:

    Free-response practice

    Write your answer first, then mark it against the scoring guide.

    Inference (full test) · 4 points

    Independent random samples of 100 customers at two branches of a bank rated service as poor, fair or good. Branch 1: 60 good, 40 not good; Branch 2: 45 good, 55 not good (collapsed into two categories). χ²-Test gives χ² ≈ 4.51, df = 1.

    1. (a) State the hypotheses and check the conditions.
    2. (b) Find the p-value.
    3. (c) Conclude at α = 0.05.

    Connected topics

    Frequently asked questions

    Do I need to list every expected count?

    Show one calculation and give the rest, or say all are at least 5 with the smallest value stated.

    What does df mean in practice?

    It is the number of cells that can vary freely once the row and column totals are fixed.

    Can a chi-square test tell me which groups differ?

    Not formally, but the largest components point to where the biggest differences from H₀ are.

    How this shows up on the exam42 multiple-choice questions and 4 free-response questions of 10 points. See what each one asks you to do.Full-length AP Statistics practice examsUnit 3 is one of 5 units on the exam. Two timed exams in the 2027 format (42 MCQ + 4 FRQ), with explanations, scoring guides and an estimated 1–5 score. $14.99 · try 5 questions free.

    Free Unit 3 cheat sheet

    Every topic in Unit 3: Inference for Categorical Data: Proportions on a few printable pages: the core idea, key terms, the two traps students fall into and what the exam asks.

    We'll use your email to tell you when new AP Statistics practice material is ready. No spam, and we'll delete it if you ask.

    Free Unit 3 practice test: 75 questions with explanations

    All topics in Unit 3: Inference for Categorical Data: Proportions

    1. 3.1 Estimators
    2. 3.2 Sampling Distributions for Sample Proportions
    3. 3.3 Constructing a Confidence Interval for a Population Proportion
    4. 3.4 Justifying a Claim Based on a Confidence Interval for a Population Proportion
    5. 3.5 Setting Up a Test for a Population Proportion
    6. 3.6 p-Values
    7. 3.7 Carrying Out a Test for a Population Proportion
    8. 3.8 Potential Errors When Performing Tests
    9. 3.9 Sampling Distributions for the Difference Between Sample Proportions
    10. 3.10 Constructing a Confidence Interval for the Difference Between Two Population Proportions
    11. 3.11 Justifying a Claim Based on a Confidence Interval for the Difference Between Two Population Proportions
    12. 3.12 Setting Up a Test for the Difference Between Two Population Proportions
    13. 3.13 Carrying Out a Test for the Difference Between Two Population Proportions
    14. 3.14 Setting Up a Chi-Square Test for Homogeneity or Independence
    15. 3.15 Carrying Out a Chi-Square Test for Homogeneity or Independence

    Other units in AP Statistics

    AP® is a trademark registered by College Board, which is not affiliated with, and does not endorse, this website.