StatisticsComparing Two Groups3 of 6
Comparing Two Groups · 3

Two-Sample z-Test for a Difference in Proportions

When two groups in a study show different success rates, we need a way to tell whether the difference between them is real or just the natural bounce of random luck.

1

Setting Up the Hypotheses

Suppose we test a new migraine pill on 150150 patients and a standard pill on 300300 patients, and we want to know whether the 9%\stat{9\%} gap between their recovery rates (26%\stat{26\%} versus 17%\stat{17\%}) gives convincing evidence that the new pill actually works better.

Random Bounce and the Hypotheses
new\text{new}
Group A\text{Group A}
n1=150n_1 = 150
39\htmlClass{lc-blue}{39}
p^1=26%\htmlClass{lc-blue}{\hat{p}_1} = \htmlClass{lc-blue}{26\%}
old\text{old}
Group B\text{Group B}
n2=300n_2 = 300
51\htmlClass{lc-blue}{51}
p^2=17%\htmlClass{lc-blue}{\hat{p}_2} = \htmlClass{lc-blue}{17\%}
10%10\%
15%15\%
20%20\%
25%25\%
30%30\%
9% gap: better pill, or luck?\htmlClass{lc-blue}{9\%}\ \text{gap: better pill, or luck?}

To see whether pure luck could easily produce a 9%\stat{9\%} gap, we start by assuming there is no real difference between the two pills' true rates p1\truth{p_1} and p2\truth{p_2}:

H0:p1−p2=0(or p1=p2)⏟null hypothesis (no real difference)Ha:p1>p2orp1≠p2⏟alternative hypothesis (what we test for)\displaystyle \begin{aligned} &\underbrace{H_0: \truth{p_1} - \truth{p_2} = \truth{0} \quad (\text{or } \truth{p_1} = \truth{p_2})}_{\text{null hypothesis (no real difference)}} \\[14pt] &\underbrace{H_a: \truth{p_1} > \truth{p_2} \quad \text{or} \quad \truth{p_1} \neq \truth{p_2}}_{\text{alternative hypothesis (what we test for)}} \end{aligned}

The plain letters p1\truth{p_1} and p2\truth{p_2} stand for the true population rates we don't know, while the hats on p^1=0.26\stat{\hat{p}_1} = \stat{0.26} and p^2=0.17\stat{\hat{p}_2} = \stat{0.17} mark the sample rates we actually saw in our data.

2

Pooling the Groups to Estimate the Shared Rate

Under the null hypothesis p1=p2\truth{p_1} = \truth{p_2}, both groups have the exact same true recovery rate, so we need a single best estimate of that shared rate before we can measure how much the samples bounce around it.

Pooling the Groups to Estimate a Shared Rate
H0 ⁣:p1=p2H_0\!: \htmlClass{lc-violet}{p_1} = \htmlClass{lc-violet}{p_2}
new\text{new}
Group A\text{Group A}
n1=150n_1 = 150
39\htmlClass{lc-blue}{39}
p^1=26%\htmlClass{lc-blue}{\hat{p}_1} = \htmlClass{lc-blue}{26\%}
old\text{old}
Group B\text{Group B}
n2=300n_2 = 300
51\htmlClass{lc-blue}{51}
p^2=17%\htmlClass{lc-blue}{\hat{p}_2} = \htmlClass{lc-blue}{17\%}
10%10\%
15%15\%
20%20\%
25%25\%
30%30\%
p^c= ?\htmlClass{lc-violet}{\hat{p}_c} = \ ?
Text solution
Combine both groups into one poolBecause the null hypothesis assumes the two pills work the same, we add all recoveries together and divide by the total number of patients across both groups.
p^c⏟pooled proportion\displaystyle \underbrace{\truth{\hat{p}_c}}_{\text{pooled proportion}} =39+51150+300\displaystyle = \frac{\counted{39} + \counted{51}}{150 + 300} =90450\displaystyle = \frac{\counted{90}}{450} =0.20\displaystyle = \truth{0.20} =20%\displaystyle = \truth{20\%}

So under H0H_0, our best estimate of the shared recovery rate is 20%\truth{20\%}, which sits closer to Group B's 17%\stat{17\%} than to Group A's 26%\stat{26\%} because Group B has twice as many patients (300300 versus 150150).

Try changing how the 450450 patients are split between the two groups to see how the larger group pulls the pooled proportion p^c\truth{\hat{p}_c} toward its own rate, only landing halfway at 21.5%21.5\% when the groups are equal in size.

Pooling weights each group by its size, so the combined rate gets pulled toward whichever group has more people instead of just sitting halfway between them.
3

Finding the Standard Error with the Pooled Proportion

A single sample proportion bounces around its true rate p\truth{p} with variance p(1−p)n\frac{\truth{p}(\truth{1 - p})}{n}, and when we subtract two independent sample proportions p^1−p^2\stat{\hat{p}_1 - \hat{p}_2}, both groups bounce at the same time, so their variances add together:

Variance of (p^1−p^2)\displaystyle \text{Variance of }(\stat{\hat{p}_1 - \hat{p}_2}) =p1(1−p1)n1+p2(1−p2)n2\displaystyle = \frac{\truth{p_1}(\truth{1 - p_1})}{n_1} + \frac{\truth{p_2}(\truth{1 - p_2})}{n_2}

Now we want to use this variance to find the standard error (the typical random bounce) of the gap p^1−p^2\stat{\hat{p}_1 - \hat{p}_2} when both groups share the 20%\truth{20\%} pooled rate.

Finding the Standard Error with the Pooled Proportion
H0 ⁣:p1=p2H_0\!: \htmlClass{lc-violet}{p_1} = \htmlClass{lc-violet}{p_2}
n1n_1
=150{} = 150
n2n_2
=300{} = 300
p^c\htmlClass{lc-violet}{\hat{p}_c}
=0.20{} = \htmlClass{lc-violet}{0.20}
Standard Error= ?\text{Standard Error} = \ ?
Group A\text{Group A}
Group B\text{Group B}
10%10\%
15%15\%
20%\htmlClass{lc-violet}{20\%}
25%25\%
30%30\%
Confidence interval: no H0\text{Confidence interval: no}\ H_0
Group A\text{Group A}
Group B\text{Group B}
10%10\%
15%15\%
20%20\%
25%25\%
30%30\%
35%35\%
p^1=26%\htmlClass{lc-blue}{\hat{p}_1} = \htmlClass{lc-blue}{26\%}
p^2=17%\htmlClass{lc-blue}{\hat{p}_2} = \htmlClass{lc-blue}{17\%}
Significance test: assumes H0 ⁣:p1=p2\text{Significance test: assumes}\ H_0\!: \htmlClass{lc-violet}{p_1} = \htmlClass{lc-violet}{p_2}
Group A\text{Group A}
Group B\text{Group B}
10%10\%
15%15\%
20%20\%
25%25\%
30%30\%
35%35\%
p^c=20%\htmlClass{lc-violet}{\hat{p}_c} = \htmlClass{lc-violet}{20\%}
Text solution
Check the normal-curve conditionsPatients were randomly assigned to the two independent groups, and each group has at least 1010 successes (recoveries) and 1010 failures (non-recoveries), so a normal bell curve models the random bounce well.
Group A: 39 recoveries,  150−39=111 non-recoveriesGroup B: 51 recoveries,  300−51=249 non-recoveries\displaystyle \begin{aligned} &\text{Group A: } \counted{39} \text{ recoveries}, \; \\ &150 - \counted{39} = \uncounted{111} \text{ non-recoveries} \\[6pt] &\text{Group B: } \counted{51} \text{ recoveries}, \; \\ &300 - \counted{51} = \uncounted{249} \text{ non-recoveries} \end{aligned}
Put the pooled rate into both variance fractionsBecause H0H_0 assumes both groups share the rate p^c=0.20\truth{\hat{p}_c} = \truth{0.20} (with 1−p^c=0.80\truth{1 - \hat{p}_c} = \truth{0.80}), we put 0.20×0.80\truth{0.20} \times \truth{0.80} into the top of both fractions, add them, and take the square root.
Standard Error=0.20×0.80150+0.20×0.80300=0.16(1150+1300)=0.16×1100=0.0016=0.04=4%\displaystyle \begin{aligned} &\text{Standard Error} \\ &= \sqrt{\frac{\truth{0.20} \times \truth{0.80}}{150} + \frac{\truth{0.20} \times \truth{0.80}}{300}} \\ &= \sqrt{0.16\left(\frac{1}{150} + \frac{1}{300}\right)} \\ &= \sqrt{0.16 \times \frac{1}{100}} \\ &= \sqrt{\spread{0.0016}} = \spread{0.04} = \spread{4\%} \end{aligned}

So if the two pills are truly identical, random assignment alone will typically make the two group recovery rates differ by about 4%\spread{4\%} one way or the other.

4

The z\steps{z}-Statistic, p\share{p}-Value, and Test Formula

Now we want to measure how many 4%\spread{4\%} standard errors our observed 9%\stat{9\%} gap sits away from 0%\truth{0\%}, and find the probability that random luck alone would create a gap at least that wide.

The z-Statistic, p-Value, and Test Formula
gap we saw\text{gap we saw}
=9%{} = \htmlClass{lc-blue}{9\%}
typical bounce\text{typical bounce}
=4%{} = \htmlClass{lc-pink}{4\%}
z\htmlClass{lc-pink}{z}
= ?{} = \ ?
p-value\htmlClass{lc-green}{p}\htmlClass{lc-green}{\text{-value}}
= ?{} = \ ?
4%\htmlClass{lc-pink}{4\%}
9%\htmlClass{lc-blue}{9\%}
−16%-16\%
−8%-8\%
0%\htmlClass{lc-violet}{0\%}
8%8\%
16%16\%
Text solution
Divide the observed gap by the standard errorComparing the 9%\stat{9\%} observed gap (p^1−p^2=0.26−0.17=0.09\stat{\hat{p}_1 - \hat{p}_2} = \stat{0.26} - \stat{0.17} = \stat{0.09}) to the 4%\spread{4\%} typical bounce tells us how many standard errors our result sits from 0\truth{0}.
z⏟standard errors from 0\displaystyle \underbrace{\steps{z}}_{\text{standard errors from } \truth{0}} =(0.26−0.17)−00.04\displaystyle = \frac{(\stat{0.26} - \stat{0.17}) - \truth{0}}{\spread{0.04}} =0.090.04\displaystyle = \frac{\stat{0.09}}{\spread{0.04}} =2.25\displaystyle = \steps{2.25}
Find the tail area for the p\share{p}-valueOn a normal curve, the area beyond z=2.25\steps{z} = \steps{2.25} in the right tail is 0.012\share{0.012} for a one-sided test (Ha:p1>p2H_a: \truth{p_1} > \truth{p_2}), which we double to include equally wide gaps beyond −9%\stat{-9\%} (z=−2.25\steps{z} = \steps{-2.25}) in the left tail for a two-sided test (Ha:p1≠p2H_a: \truth{p_1} \neq \truth{p_2}).
One-sided p-value=0.012 (1.2%)Two-sided p-value=2×0.012=0.024 (2.4%)\displaystyle \begin{aligned} \text{One-sided } \share{p}\text{-value} &= \share{0.012} \text{ } (\share{1.2\%}) \\ \text{Two-sided } \share{p}\text{-value} &= 2 \times \share{0.012} \\ &= \share{0.024} \text{ } (\share{2.4\%}) \end{aligned}
Compare the p\share{p}-value to the α=0.05\cutoff{\alpha} = \cutoff{0.05} cutoffBecause pure luck would produce a gap of 9%\stat{9\%} or wider in either direction only 2.4%\share{2.4\%} of the time when the pills are identical, and a gap that wide in favor of the new pill only 1.2%\share{1.2\%} of the time, both p\share{p}-values are below our 5%\cutoff{5\%} cutoff, so we reject H0H_0 with either alternative.
0.012<0.05and0.024<0.05  ⟹  Reject H0\displaystyle \begin{aligned} \share{0.012} &< \cutoff{0.05} \quad \text{and} \\ \share{0.024} &< \cutoff{0.05} \implies \text{Reject } H_0 \end{aligned}

Because patients were randomly assigned to the two groups, rejecting H0H_0 gives convincing evidence of cause and effect: the new migraine pill works better than the old one.

Putting the observed gap on top and the pooled standard error on the bottom gives the complete formula for the Two-Sample z\steps{z}-Test for a Difference in Proportions:

z=(p^1−p^2)−0⏞observed gap from 0p^c(1−p^c)(1n1+1n2)⏟typical random bounce under p1=p2where p^c=total successesn1+n2\displaystyle \fbox{$\begin{aligned} \steps{z} &= \frac{\overbrace{(\stat{\hat{p}_1} - \stat{\hat{p}_2}) - \truth{0}}^{\text{observed gap from } \truth{0}}}{\underbrace{\sqrt{\truth{\hat{p}_c}(\truth{1 - \hat{p}_c})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}_{\text{typical random bounce under } \truth{p_1} = \truth{p_2}}} \\[16pt] \text{where } \truth{\hat{p}_c} &= \frac{\counted{\text{total successes}}}{n_1 + n_2} \end{aligned}$}

In practice, once you see a gap is more than 2\steps{2} standard errors from zero (∣z∣>2|\steps{z}| > \steps{2}) in the direction HaH_a predicts (either direction for ≠\neq), you can already tell the p\share{p}-value will fall below the usual α=0.05\cutoff{\alpha} = \cutoff{0.05} cutoff, though you still need to write out the conditions, the pooled proportion p^c\truth{\hat{p}_c}, the z\steps{z}-statistic, and the p\share{p}-value.

Move the observed gap along the bell curve to see the tail area shrink as the gap moves farther from zero, and how switching to a two-sided test counts both tails and doubles the p\share{p}-value, so both tails together drop below the 5%\cutoff{5\%} cutoff only past about 2\steps{2} standard errors (8%\spread{8\%}).

The more standard-deviation steps the gap sits from the center, the smaller the tail beyond it, and a two-sided test doubles that tail by counting the matching gap on the other side.

Key concepts

When you test whether two proportions are equal (H0:p1−p2=0H_0: \truth{p_1} - \truth{p_2} = \truth{0}), every step follows from assuming the two groups share the same true rate. Before using the normal curve, check that the two groups are independent (through random assignment or two independent random samples) and that each group separately has at least 1010 successes and 1010 failures (39\counted{39} and 111\uncounted{111} in Group A; 51\counted{51} and 249\uncounted{249} in Group B). Because H0H_0 assumes p1=p2\truth{p_1} = \truth{p_2}, combine both groups to estimate their shared rate p^c=39+51150+300=0.20\truth{\hat{p}_c} = \frac{\counted{39} + \counted{51}}{150 + 300} = \truth{0.20} and use p^c\truth{\hat{p}_c} in both variance fractions of the test statistic:

z=(p^1−p^2)−0p^c(1−p^c)(1n1+1n2)=0.26−0.170.20(0.80)(1150+1300)=2.25\displaystyle \begin{aligned} \steps{z} &= \frac{(\stat{\hat{p}_1} - \stat{\hat{p}_2}) - \truth{0}}{\sqrt{\truth{\hat{p}_c}(\truth{1 - \hat{p}_c})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}} \\[4pt] &= \frac{\stat{0.26} - \stat{0.17}}{\sqrt{\truth{0.20}(\truth{0.80})\left(\frac{1}{150} + \frac{1}{300}\right)}} \\[4pt] &= \steps{2.25} \end{aligned}

Do not pool when building a confidence interval for p1−p2\truth{p_1 - p_2}: a confidence interval has no null hypothesis, so each group keeps its own sample rate inside the square root, 0.26(0.74)150+0.17(0.83)300\sqrt{\frac{\stat{0.26}(\stat{0.74})}{150} + \frac{\stat{0.17}(\stat{0.83})}{300}}. Finally, match the p\share{p}-value to your original question (one tail for p1>p2\truth{p_1} > \truth{p_2}, giving p=0.012\share{p} = \share{0.012}, or both tails for p1≠p2\truth{p_1} \neq \truth{p_2}, giving p=0.024\share{p} = \share{0.024}) and check how the data were collected before stating your conclusion: rejecting H0H_0 in a randomized experiment gives convincing evidence of cause and effect, whereas rejecting H0H_0 with two independent random samples from an observational study only gives convincing evidence that the two populations differ.

5

Practice

1

In a study comparing two exam prep methods, 100100 students using Method 1 had a 76%\stat{76\%} pass rate (p^1=0.76\stat{\hat{p}_1} = \stat{0.76}), and 300300 students using Method 2 had a 60%\stat{60\%} pass rate (p^2=0.60\stat{\hat{p}_2} = \stat{0.60}). Calculate the pooled proportion p^c\truth{\hat{p}_c} under the null hypothesis p1=p2\truth{p_1} = \truth{p_2}, and explain why it is not halfway between 76%\stat{76\%} and 60%\stat{60\%}.

How many students passed in each group before you combine all 400400 students into a single pool?

Method 1 had 0.76×100=76\stat{0.76} \times 100 = \counted{76} passes and Method 2 had 0.60×300=180\stat{0.60} \times 300 = \counted{180} passes. Combining both groups gives:
p^c\displaystyle \truth{\hat{p}_c} =76+180100+300\displaystyle = \frac{\counted{76} + \counted{180}}{100 + 300} =256400\displaystyle = \frac{\counted{256}}{400} =0.64\displaystyle = \truth{0.64} =64%\displaystyle = \truth{64\%}
(Watch out: averaging the two percentages directly as 76%+60%2=68%\frac{\stat{76\%} + \stat{60\%}}{2} = 68\% is a common mistake that ignores group sizes.) The pooled rate sits closer to 60%\stat{60\%} than to 76%\stat{76\%} because Method 2 had three times as many students, pulling the combined rate closer to 60%\stat{60\%}.
2

A retailer randomly assigns 200200 online shoppers to two checkout layouts. In Group 1, 44\counted{44} of 5050 shoppers complete their purchase. In Group 2, 120\counted{120} of 150150 shoppers complete their purchase. Are the conditions met to model the random bounce with a normal bell curve? Check both conditions.

Check independence first, then count both completed purchases and non-purchases in each group separately.

No. The independence condition is met because shoppers were randomly assigned to the two groups, and Group 2 has 120\counted{120} successes and 150−120=30150 - \counted{120} = \uncounted{30} failures (both at least 1010). However, in Group 1:
Successes=44,Failures=50−44=6<10\displaystyle \begin{aligned} \text{Successes} &= \counted{44}, \\ \text{Failures} &= 50 - \counted{44} = \uncounted{6} < 10 \end{aligned}
(Watch out: checking only the combined pool of 44+120=164\counted{44} + \counted{120} = \counted{164} successes and 6+30=36\uncounted{6} + \uncounted{30} = \uncounted{36} failures, or checking only successes, makes it look like the condition is met when it isn't.) Because Group 1 has only 6\uncounted{6} failures, which is fewer than the required 1010 failures, the normal-curve condition is not met.
3

A researcher compares two physical therapy routines where Routine 1 has p^1=0.55\stat{\hat{p}_1} = \stat{0.55} (n1=200n_1 = 200), Routine 2 has p^2=0.45\stat{\hat{p}_2} = \stat{0.45} (n2=200n_2 = 200), and the pooled proportion is p^c=0.50\truth{\hat{p}_c} = \truth{0.50}. She writes two formulas for the standard error:

Formula A:0.55×0.45200+0.45×0.55200Formula B:0.50×0.50200+0.50×0.50200\displaystyle \begin{aligned} &\text{Formula A:} \\ &\sqrt{\tfrac{0.55 \times 0.45}{200} + \tfrac{0.45 \times 0.55}{200}} \\[8pt] &\text{Formula B:} \\ &\sqrt{\tfrac{0.50 \times 0.50}{200} + \tfrac{0.50 \times 0.50}{200}} \end{aligned}

Which formula belongs to a two-sample z\steps{z}-test for H0:p1−p2=0H_0: \truth{p_1} - \truth{p_2} = \truth{0}, which belongs to a confidence interval, and why do they use different proportions?

Which procedure starts by assuming both routines have the exact same true success rate?

Formula B belongs to the two-sample z\steps{z}-test and Formula A belongs to the confidence interval. (Watch out: plugging the separate sample rates 0.55\stat{0.55} and 0.45\stat{0.45} into the significance test gives Formula A's 0.002475≈0.0497\sqrt{\spread{0.002475}} \approx \spread{0.0497} instead of Formula B's 0.0025=0.0500\sqrt{\spread{0.0025}} = \spread{0.0500}, which goes against the null hypothesis you are testing.) A confidence interval has no null hypothesis, so each group estimates its own bounce using its own sample proportion (0.55\stat{0.55} and 0.45\stat{0.45}). A significance test assumes the null hypothesis p1=p2\truth{p_1} = \truth{p_2} is true, meaning both groups share a single true rate estimated by the pooled proportion (0.50\truth{0.50}).
4

An agricultural experiment randomly assigns 800800 tomato plants to two fertilizers to test if Fertilizer 1 produces a higher proportion of pest-free plants than Fertilizer 2. Out of 200200 plants given Fertilizer 1, 132\counted{132} are pest-free. Out of 600600 plants given Fertilizer 2, 348\counted{348} are pest-free. State H0H_0 and HaH_a, find the pooled proportion p^c\truth{\hat{p}_c}, the standard error, and the z\steps{z}-statistic, and use the fact that the area to the right of z=2.00\steps{z} = \steps{2.00} on a normal curve is 0.023\share{0.023} to draw a conclusion at α=0.05\cutoff{\alpha} = \cutoff{0.05}.

Find the separate sample rates p^1\stat{\hat{p}_1} and p^2\stat{\hat{p}_2} for the observed gap on top of the z\steps{z} fraction, then pool all 800800 plants to get p^c\truth{\hat{p}_c} for the bottom.

The hypotheses are H0:p1−p2=0H_0: \truth{p_1} - \truth{p_2} = \truth{0} (or p1=p2\truth{p_1} = \truth{p_2}) and Ha:p1>p2H_a: \truth{p_1} > \truth{p_2}. The sample proportions are p^1=132200=0.66\stat{\hat{p}_1} = \frac{\counted{132}}{200} = \stat{0.66} (66%\stat{66\%}) and p^2=348600=0.58\stat{\hat{p}_2} = \frac{\counted{348}}{600} = \stat{0.58} (58%\stat{58\%}), giving an observed gap of 0.66−0.58=0.08\stat{0.66} - \stat{0.58} = \stat{0.08} (8%\stat{8\%}). The pooled proportion is:
p^c\displaystyle \truth{\hat{p}_c} =132+348200+600\displaystyle = \frac{\counted{132} + \counted{348}}{200 + 600} =480800\displaystyle = \frac{\counted{480}}{800} =0.60(60%)\displaystyle = \truth{0.60} \quad (\truth{60\%})
(Watch out: averaging 0.66\stat{0.66} and 0.58\stat{0.58} directly gives p^c=0.62\truth{\hat{p}_c} = 0.62, which throws off the standard error to 0.03960.0396 and z\steps{z} to 2.022.02.) Using p^c=0.60\truth{\hat{p}_c} = \truth{0.60}, the standard error and z\steps{z}-statistic are:
Standard Error=0.60×0.40×(1200+1600)=0.24×1150=0.0016=0.04(4%)\displaystyle \begin{aligned} \text{Standard Error} &= \sqrt{\truth{0.60} \times \truth{0.40} \times \left(\frac{1}{200} + \frac{1}{600}\right)} \\ &= \sqrt{0.24 \times \frac{1}{150}} \\ &= \sqrt{\spread{0.0016}} = \spread{0.04} \quad (\spread{4\%}) \end{aligned}
z\displaystyle \steps{z} =0.08−00.04\displaystyle = \frac{\stat{0.08} - \truth{0}}{\spread{0.04}} =2.00\displaystyle = \steps{2.00}
The observed 8%\stat{8\%} gap is 2\steps{2} standard errors above zero, giving a one-sided p\share{p}-value of 0.023\share{0.023}. Since 0.023<0.05\share{0.023} < \cutoff{0.05}, we reject H0H_0; because plants were randomly assigned, there is convincing evidence that Fertilizer 1 causes a higher pest-free rate than Fertilizer 2.
5

Two software versions are tested on randomly assigned users with p^1−p^2=−6%\stat{\hat{p}_1 - \hat{p}_2} = \stat{-6\%} and a pooled standard error of 3.2%\spread{3.2\%}, giving z=−1.875\steps{z} = \steps{-1.875}. The area in a single tail beyond z=−1.875\steps{z} = \steps{-1.875} is 0.030\share{0.030}. State the p\share{p}-value and the decision at α=0.05\cutoff{\alpha} = \cutoff{0.05} if the original question before looking at the data was (a) one-sided, Ha:p1<p2H_a: \truth{p_1} < \truth{p_2}, versus (b) two-sided, Ha:p1≠p2H_a: \truth{p_1} \neq \truth{p_2}, and explain in plain English what the two-sided p\share{p}-value means.

Which alternative hypothesis counts wide gaps in only one direction, and which counts equally wide gaps in both directions?

(a)For Ha:p1<p2H_a: \truth{p_1} < \truth{p_2}, the one-sided p\share{p}-value is 0.030\share{0.030}; since 0.030<0.05\share{0.030} < \cutoff{0.05}, we reject H0H_0.
(b)For Ha:p1≠p2H_a: \truth{p_1} \neq \truth{p_2}, we count both tails (gaps at or beyond −6%\stat{-6\%} and +6%\stat{+6\%}), doubling the p\share{p}-value to 2×0.030=0.0602 \times \share{0.030} = \share{0.060}. (Watch out: forgetting to double the single-tail area leaves p=0.030p = 0.030 and leads to the wrong decision of rejecting H0H_0.) Since 0.060>0.05\share{0.060} > \cutoff{0.05}, we fail to reject H0H_0. In plain English, the two-sided p\share{p}-value of 0.060\share{0.060} means that if the two software versions had the exact same true rate, there would be a 6%\share{6\%} chance that random assignment alone would produce a gap of 6%\stat{6\%} or wider in either direction.
6

A sociologist takes two independent random samples, 500500 adults who walk to work and 500500 adults who drive to work, to test whether the two populations differ in the proportion reporting high daily energy (H0:p1=p2H_0: \truth{p_1} = \truth{p_2}, Ha:p1≠p2H_a: \truth{p_1} \neq \truth{p_2}). Both groups have more than 100100 successes and 100100 failures, and the two-sample z\steps{z}-test gives z=2.60\steps{z} = \steps{2.60} with a two-sided p\share{p}-value of 0.009\share{0.009}. At α=0.05\cutoff{\alpha} = \cutoff{0.05}, can the sociologist conclude that walking to work causes higher daily energy? Explain why or why not.

Look at how the adults ended up in the walking and driving groups: were they randomly assigned?

No. Because p=0.009<0.05\share{p} = \share{0.009} < \cutoff{0.05} and the independent random samples and 1010-successes/1010-failures conditions are met, the sociologist can reject H0H_0 and conclude there is a real difference in the proportion reporting high energy between walkers and drivers. (Watch out: answering "Yes" because p=0.009<0.05\share{p} = \share{0.009} < \cutoff{0.05} confuses a real difference between groups with cause and effect.) Because this was an observational study rather than an experiment with random assignment, other differences between the two groups could explain the gap, so it cannot prove cause and effect.