AP Statistics · Study guide

Same decision. Two samples.

AP® Statistics · Unit 3 · Inference for Categorical Data: Proportions

Carrying Out a Test for a Difference in Proportions

How to compute the two-sample z test statistic with the pooled proportion, find and interpret the p-value, and write a conclusion in context about the difference between two population proportions.

The idea in one paragraph

Assume the two population proportions are equal. Then measure how far the observed difference \(\hat{p}_1 - \hat{p}_2\) is from 0, in standard deviations: that is the z test statistic. The p-value is how often a difference at least that far out would happen by chance if H₀ were true. A small p-value is convincing evidence of a difference.

1The test statistic

\[ z = \frac{(\hat{p}_1 - \hat{p}_2) - 0}{\sqrt{\hat{p}_c(1 - \hat{p}_c)\left(\dfrac{1}{n_1} + \dfrac{1}{n_2}\right)}}, \qquad \hat{p}_c = \frac{n_1\hat{p}_1 + n_2\hat{p}_2}{n_1 + n_2} \]

The numerator is the observed difference minus the difference H₀ claims, 0. The denominator is the standard deviation of \(\hat{p}_1 - \hat{p}_2\) when H₀ is true. Because H₀ says the two proportions are equal, it uses one shared estimate: the pooled proportion \(\hat{p}_c\), the proportion of successes for the two groups combined. When the null hypothesis is true, z has a standard normal distribution.

Figure 1. If H₀ is true, the difference in sample proportions varies around 0 with standard deviation 0.0625 (from the pooled proportion). The observed 0.15 is 2.40 standard deviations above 0. The area to its right, 0.0082, is the one-sided p-value.
Common Mistake 1 · Using the interval’s standard error in the test

A confidence interval uses each sample’s own \(\hat{p}\) because it assumes nothing about the proportions. A test assumes H₀, so it uses \(\hat{p}_c\) in both places. For the texting data the pooled standard error is 0.0625; the separate one is 0.0617. The difference is small here, but the procedures are not interchangeable.

2The p-value

The p-value comes from the standard normal distribution, using a table or technology. It is the probability of a test statistic as extreme as or more extreme than the one observed, in the direction of the alternative, assuming H₀ is true.

Alternativep-value
\(H_a: p_1 - p_2 \gt 0\)\(P(Z \ge z)\), the right tail
\(H_a: p_1 - p_2 \lt 0\)\(P(Z \le z)\), the left tail
\(H_a: p_1 - p_2 \ne 0\)\(2P(Z \ge |z|)\), both tails
Figure 2. The alternative p₁ ≠ p₂ counts a difference this large in either direction as evidence, so the p-value includes both tails.
Worked Example 1 Interpret the p-value

Reminder texts

Interpret the p-value of 0.0082 from the reminder-text test.

  1. 1Start with the assumption: H₀ in context, the two treatments have the same turn-in proportion.
  2. 2Then the observed result and the direction of the alternative: a difference of 0.15 or more.
  3. 3Finish with the group sizes: 120 and 120.
Answer: Assuming that a reminder text makes no difference in the proportion of students like these who turn in missed work, there is a 0.0082 probability of getting a difference in sample proportions (text minus no text) of 0.15 or more in groups of 120 and 120.
Say it like this

“Assuming that a reminder text makes no difference in the proportion of students like these who turn in missed work, there is a 0.0082 probability of getting a difference in sample proportions (text minus no text) of 0.15 or more in groups of 120 and 120.”

Figure 3. Shuffling the outcomes between the two groups shows what random assignment alone produces when texts have no effect. A difference of 0.15 or more came up 11 times in 1,000, about 1.1%. The z-test’s 0.0082 tells the same story: chance alone rarely produces a gap this big.
Common Mistake 2 · Reading the p-value as the probability that H₀ is true

The p-value of 0.0082 is computed assuming H₀ is true. It is the probability of data like ours under that assumption, not the probability that texts have no effect.

3The decision and the conclusion

The formal decision compares the p-value with the significance level α. If the p-value ≤ α, reject \(H_0\). If the p-value \(\gt\) α, fail to reject \(H_0\). Then answer the question in context, in terms of the alternative hypothesis, with non-definitive language, naming the parameters and the populations.

The conclusion, start to finish

“Because the p-value of 0.0082 is less than α = 0.05, we reject H₀. There is convincing evidence that a reminder text increases the proportion of students like these who turn in missed work within two days.”

Common Mistake 3 · Treating “fail to reject” as evidence that the proportions are equal

With a p-value of 0.354, the lunch data are consistent with no difference, but they are also consistent with a modest one. Write “there is not convincing evidence that the proportions differ,” never “the proportions are the same.”

Common Mistake 4 · Claiming cause from two random samples

The walking test compares two schools sampled at random. It gives convincing evidence that the proportions differ, not that anything about a school causes students to walk. Cause and effect needs random assignment, as in the texting experiment.

4Three tests, start to finish

Worked Example 2 A complete one-sided test

Reminder texts

A school randomly assigned 240 students who missed an assignment to get a reminder text (120) or no text (120). 84 of the texted students and 66 of the others turned in the work within two days. Do the data give convincing evidence at \(\alpha = 0.05\) that a text increases the proportion who turn it in?

  1. 1State. \(H_0: p_1 - p_2 = 0\), \(H_a: p_1 - p_2 \gt 0\), where \(p_1\) and \(p_2\) are the true proportions of students like these who turn in missed work within two days with a text and without one. \(\alpha = 0.05\).
  2. 2Plan. Two-sample z-test for the difference between two population proportions. Randomization: treatments were randomly assigned. Normality: \(\hat{p}_c = 150/240 = 0.625\); expected counts 75, 45, 75, 45 are all at least 10.
  3. 3Do. \(\hat{p}_1 = 0.70\), \(\hat{p}_2 = 0.55\). \(z = \dfrac{0.70 - 0.55 - 0}{\sqrt{0.625(0.375)\left(\frac{1}{120} + \frac{1}{120}\right)}} = \dfrac{0.15}{0.0625} = 2.40\). p-value \(= P(Z \ge 2.40) \approx 0.0082\).
  4. 4Conclude. Because the p-value of 0.0082 is less than \(\alpha = 0.05\), we reject \(H_0\). There is convincing evidence that a reminder text increases the proportion of students like these who turn in missed work within two days.
Answer: Reject H₀. Because treatments were randomly assigned, the evidence supports a cause and effect conclusion for students like these.
On the calculator

STAT, TESTS, 2-PropZTest. Enter x1 = 84, n1 = 120, x2 = 66, n2 = 120, choose p1 > p2, and Calculate. The output shows z = 2.4, p = 0.0082, and the pooled proportion \(\hat{p} = 0.625\). The calculator pools automatically.

Worked Example 3 A two-sided test

Walking to school

Independent random samples from two large schools found 33 of 150 students at School 1 and 21 of 160 at School 2 walk to school. Test at \(\alpha = 0.05\) whether the proportions differ.

  1. 1\(H_0: p_1 = p_2\), \(H_a: p_1 \ne p_2\). Conditions: independent random samples; each sample is no more than 10% of its school; pooled expected counts 26.1, 123.9, 27.9 and 132.1 are all at least 10.
  2. 2\(\hat{p}_1 = 0.22\), \(\hat{p}_2 \approx 0.131\), difference \(\approx 0.089\). \(\hat{p}_c = 54/310 \approx 0.174\).
  3. 3\(SE = \sqrt{0.174(0.826)\left(\frac{1}{150} + \frac{1}{160}\right)} \approx 0.0431\), so \(z \approx 0.089/0.0431 \approx 2.06\).
  4. 4Two-sided: p-value \(= 2P(Z \ge 2.06) \approx 2(0.0198) = 0.0395\).
Answer: Because 0.0395 is less than 0.05, we reject H₀. There is convincing evidence that the proportion of students who walk to school differs between School 1 and School 2.
Worked Example 4 When the test fails to reject

Lunch from home

Random samples in a large school district found 62 of 180 tenth graders and 60 of 200 twelfth graders usually bring lunch from home. Test at \(\alpha = 0.05\) whether the proportions differ.

  1. 1\(H_0: p_1 = p_2\), \(H_a: p_1 \ne p_2\). Pooled \(\hat{p}_c = 122/380 \approx 0.321\); expected counts 57.8, 122.2, 64.2, 135.8 are all at least 10.
  2. 2\(\hat{p}_1 \approx 0.344\), \(\hat{p}_2 = 0.30\). \(SE \approx 0.0480\), \(z \approx 0.044/0.0480 \approx 0.93\).
  3. 3Two-sided p-value \(\approx 0.354\).
Answer: Because 0.354 is greater than 0.05, we fail to reject H₀. There is not convincing evidence that the proportions of 10th and 12th graders in the district who usually bring lunch from home differ.

Quick reference

StepWhat to write
Pooled proportion\(\hat{p}_c\) = total successes ÷ total sample size
Test statistic\(z = (\hat{p}_1 - \hat{p}_2) / \sqrt{\hat{p}_c(1-\hat{p}_c)(1/n_1 + 1/n_2)}\)
p-valueStandard normal tail(s) in the direction of \(H_a\)
Decisionp-value ≤ α: reject \(H_0\); p-value \(\gt\) α: fail to reject \(H_0\)
ConclusionConvincing evidence (or not) for \(H_a\), in context, naming both populations
Calculator2-PropZTest