Unit 3 · Topic 3.13 Beta

Carrying Out a Test for the Difference Between Two Population Proportions

4 min read · freeNot practiced

With the setup done, carrying out a two-sample z test takes three more moves: compute the test statistic, find the p-value, and write the conclusion. Each move follows from one idea: we act as if the null hypothesis were true and ask how surprising the data would be.

The test statistic

Every standardized test statistic in this course has the same form:

statistic−null valuestandard error of the statistic\dfrac{\text{statistic} - \text{null value}}{\text{standard error of the statistic}}

For two proportions the statistic is p^1−p^2\hat{p}_1 - \hat{p}_2 and the null value is 0. If H0H_0 is true, both groups share one proportion, estimated by pcp_c, so the standard error uses pcp_c for both groups:

z=(p^1−p^2)−0pc(1−pc)(1n1+1n2).z = \frac{(\hat{p}_1 - \hat{p}_2) - 0}{\sqrt{p_c(1 - p_c)\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}.

The denominator is the same as pc(1−pc)n1+pc(1−pc)n2\sqrt{\frac{p_c(1-p_c)}{n_1} + \frac{p_c(1-p_c)}{n_2}}: the variances still add, but each one uses the pooled proportion. This formula is on the reference sheet.

The p-value

Normal curve centered at 0 with standard error 0.052, the distribution of the difference in sample proportions if the null hypothesis is true; the observed difference 0.131 is marked and the small area to its right, the p-value of about 0.006, is shaded.
Figure 1. The null distribution of p^N−p^O\hat{p}_N - \hat{p}_O and the shaded p-value. LevlPrep original diagram.

The p-value is the probability, assuming H0H_0, of a difference at least as extreme as the one observed. Use the standard normal distribution and the direction of HaH_a:

  • Ha:p1−p2>0H_a: p_1 - p_2 > 0: the area to the right of zz.
  • Ha:p1−p2<0H_a: p_1 - p_2 < 0: the area to the left of zz.
  • Ha:p1−p2≠0H_a: p_1 - p_2 \ne 0: the area beyond |z||z| in both tails, twice one tail.

Worked example 1 (one-sided). The city randomly assigned 160 households a new recycling bin and 140 the old bin; 125 and 91 sorted correctly. Test at α=0.05\alpha = 0.05 whether the new bin increases correct sorting.

State. H0:pN−pO=0H_0: p_N - p_O = 0, Ha:pN−pO>0H_a: p_N - p_O > 0, where pNp_N and pOp_O are the true proportions of households like these that would sort correctly with the new and the old bin.

Plan. A two-sample z test for pN−pOp_N - p_O. Random: the bins were randomly assigned. Large counts with pc=216300=0.72p_c = \frac{216}{300} = 0.72: 160(0.72)=115.2160(0.72) = 115.2, 160(0.28)=44.8160(0.28) = 44.8, 140(0.72)=100.8140(0.72) = 100.8 and 140(0.28)=39.2140(0.28) = 39.2 are each at least 10.

Do. p^N\hat{p}_N=125160= \frac{125}{160}=0.781= 0.781 and p^O=91140=0.650\hat{p}_O = \frac{91}{140} = 0.650.

zz=0.781−0.6500.72(0.28)(1160+1140)= \frac{0.781 - 0.650}{\sqrt{0.72(0.28)\left(\frac{1}{160} + \frac{1}{140}\right)}}=0.1310.0520= \frac{0.131}{0.0520}=2.53= 2.53, and the p-value is P(Z≥2.53)=0.0058P(Z \ge 2.53) = 0.0058.

On a calculator this is a 2-proportion z test with the counts and the alternative >>; it reports the same zz and p-value.

Conclude. Because the p-value of 0.0058 is less than α=0.05\alpha = 0.05, we reject H0H_0. There is convincing evidence that the true proportion of households like these that sort their recycling correctly is greater with the new bin than with the old bin. Because the bins were randomly assigned, the new bin can be credited with the improvement, for households like these volunteers.

The figure shows why the p-value is so small: if the bin made no difference, a gap of 0.131 would be more than 2.5 standard errors from 0.

Worked example 2 (two-sided). Independent random samples of 150 residents find 45 in Lakeview and 63 in Hillcrest who take transit to work. Is there convincing evidence that the true proportions differ, at α=0.05\alpha = 0.05?

pcp_c=45+63300= \frac{45 + 63}{300}=0.36= 0.36; p^L=0.30\hat{p}_L = 0.30 and p^H=0.42\hat{p}_H = 0.42.

zz=0.30−0.420.36(0.64)(1150+1150)= \frac{0.30 - 0.42}{\sqrt{0.36(0.64)\left(\frac{1}{150} + \frac{1}{150}\right)}}=−0.120.0554= \frac{-0.12}{0.0554}=−2.17= -2.17, and the p-value is 2P(Z≤−2.17)=0.0302P(Z \le -2.17) = 0.030.

Because 0.030 is less than 0.05, we reject H0H_0. There is convincing evidence that the true proportion of residents who take transit to work is different in Lakeview and Hillcrest.

Reading a p-value and a conclusion

Interpret a p-value with its condition first: "Assuming the true proportions are equal, there is a 0.0058 probability of getting a difference in sample proportions of 0.131 or more by chance." It is never the probability that H0H_0 is true.

When the p-value is large, say "fail to reject H0H_0" and "there is not convincing evidence that ...". Never write "accept H0H_0" or "the proportions are the same": the data are consistent with no difference, but a real difference may be too small for these samples to detect.

Errors and scope

DecisionPossible errorIn the recycling study
Reject H0H_0Type Iconcluding the new bin helps when it truly makes no difference
Fail to reject H0H_0Type IImissing a real improvement from the new bin

Random assignment allows a cause-and-effect conclusion; random samples allow generalizing to the populations sampled. A study needs the matching design for each kind of conclusion. A voluntary response sample, such as people who choose to vote on a website, supports neither, however small its p-value.

Spot a mistake on this page?