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 150 patients and a standard pill on 300 patients, and we want to know whether the 9% gap between their recovery rates (26% versus 17%) gives convincing evidence that the new pill actually works better.
Random Bounce and the Hypotheses
To see whether pure luck could easily produce a 9% gap, we start by assuming there is no real difference between the two pills' true rates p1 and p2:
null hypothesis (no real difference)H0:p1−p2=0(or p1=p2)alternative hypothesis (what we test for)Ha:p1>p2orp1=p2
The plain letters p1 and p2 stand for the true population rates we don't know, while the hats on p^1=0.26 and p^2=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, 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
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.
pooled proportionp^c=150+30039+51=45090=0.20=20%
So under H0, our best estimate of the shared recovery rate is 20%, which sits closer to Group B's 17% than to Group A's 26% because Group B has twice as many patients (300 versus 150).
Try changing how the 450 patients are split between the two groups to see how the larger group pulls the pooled proportion p^c toward its own rate, only landing halfway at 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 with variance np(1−p), and when we subtract two independent sample proportions p^1−p^2, both groups bounce at the same time, so their variances add together:
Variance of (p^1−p^2)=n1p1(1−p1)+n2p2(1−p2)
Now we want to use this variance to find the standard error (the typical random bounce) of the gap p^1−p^2 when both groups share the 20% pooled rate.
Finding the Standard Error with the Pooled Proportion
Text solution
Check the normal-curve conditionsPatients were randomly assigned to the two independent groups, and each group has at least 10 successes (recoveries) and 10 failures (non-recoveries), so a normal bell curve models the random bounce well.
Put the pooled rate into both variance fractionsBecause H0 assumes both groups share the rate p^c=0.20 (with 1−p^c=0.80), we put 0.20×0.80 into the top of both fractions, add them, and take the square root.
So if the two pills are truly identical, random assignment alone will typically make the two group recovery rates differ by about 4% one way or the other.
4
The z-Statistic, p-Value, and Test Formula
Now we want to measure how many 4% standard errors our observed 9% gap sits away from 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
Text solution
Divide the observed gap by the standard errorComparing the 9% observed gap (p^1−p^2=0.26−0.17=0.09) to the 4% typical bounce tells us how many standard errors our result sits from 0.
standard errors from 0z=0.04(0.26−0.17)−0=0.040.09=2.25
Find the tail area for the p-valueOn a normal curve, the area beyond z=2.25 in the right tail is 0.012 for a one-sided test (Ha:p1>p2), which we double to include equally wide gaps beyond −9% (z=−2.25) in the left tail for a two-sided test (Ha:p1=p2).
Compare the p-value to the α=0.05 cutoffBecause pure luck would produce a gap of 9% or wider in either direction only 2.4% of the time when the pills are identical, and a gap that wide in favor of the new pill only 1.2% of the time, both p-values are below our 5% cutoff, so we reject H0 with either alternative.
0.0120.024<0.05and<0.05⟹Reject H0
Because patients were randomly assigned to the two groups, rejecting H0 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-Test for a Difference in Proportions:
zwhere p^c=typical random bounce under p1=p2p^c(1−p^c)(n11+n21)(p^1−p^2)−0observed gap from 0=n1+n2total successes
In practice, once you see a gap is more than 2 standard errors from zero (∣z∣>2) in the direction Ha predicts (either direction for =), you can already tell the p-value will fall below the usual α=0.05 cutoff, though you still need to write out the conditions, the pooled proportion p^c, the z-statistic, and the 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-value, so both tails together drop below the 5% cutoff only past about 2 standard errors (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=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 10 successes and 10 failures (39 and 111 in Group A; 51 and 249 in Group B). Because H0 assumes p1=p2, combine both groups to estimate their shared rate p^c=150+30039+51=0.20 and use p^c in both variance fractions of the test statistic:
Do not pool when building a confidence interval for p1−p2: a confidence interval has no null hypothesis, so each group keeps its own sample rate inside the square root, 1500.26(0.74)+3000.17(0.83). Finally, match the p-value to your original question (one tail for p1>p2, giving p=0.012, or both tails for p1=p2, giving p=0.024) and check how the data were collected before stating your conclusion: rejecting H0 in a randomized experiment gives convincing evidence of cause and effect, whereas rejecting H0 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, 100 students using Method 1 had a 76% pass rate (p^1=0.76), and 300 students using Method 2 had a 60% pass rate (p^2=0.60). Calculate the pooled proportion p^c under the null hypothesis p1=p2, and explain why it is not halfway between 76% and 60%.
Watch out: averaging the two percentages directly as 276%+60%=68% is a common mistake that ignores group sizes.
How many students passed in each group before you combine all 400 students into a single pool?
Method 1 had 0.76×100=76 passes and Method 2 had 0.60×300=180 passes. Combining both groups gives:
p^c=100+30076+180=400256=0.64=64%
(Watch out: averaging the two percentages directly as 276%+60%=68% is a common mistake that ignores group sizes.) The pooled rate sits closer to 60% than to 76% because Method 2 had three times as many students, pulling the combined rate closer to 60%.
2
A retailer randomly assigns 200 online shoppers to two checkout layouts. In Group 1, 44 of 50 shoppers complete their purchase. In Group 2, 120 of 150 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 successes and 150−120=30 failures (both at least 10). However, in Group 1:
SuccessesFailures=44,=50−44=6<10
(Watch out: checking only the combined pool of 44+120=164 successes and 6+30=36 failures, or checking only successes, makes it look like the condition is met when it isn't.) Because Group 1 has only 6 failures, which is fewer than the required 10 failures, the normal-curve condition is not met.
3
A researcher compares two physical therapy routines where Routine 1 has p^1=0.55 (n1=200), Routine 2 has p^2=0.45 (n2=200), and the pooled proportion is p^c=0.50. She writes two formulas for the standard error:
Which formula belongs to a two-sample z-test for H0:p1−p2=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-test and Formula A belongs to the confidence interval. (Watch out: plugging the separate sample rates 0.55 and 0.45 into the significance test gives Formula A's 0.002475≈0.0497 instead of Formula B's 0.0025=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 and 0.45). A significance test assumes the null hypothesis p1=p2 is true, meaning both groups share a single true rate estimated by the pooled proportion (0.50).
4
An agricultural experiment randomly assigns 800 tomato plants to two fertilizers to test if Fertilizer 1 produces a higher proportion of pest-free plants than Fertilizer 2. Out of 200 plants given Fertilizer 1, 132 are pest-free. Out of 600 plants given Fertilizer 2, 348 are pest-free. State H0 and Ha, find the pooled proportion p^c, the standard error, and the z-statistic, and use the fact that the area to the right of z=2.00 on a normal curve is 0.023 to draw a conclusion at α=0.05.
Watch out: averaging 0.66 and 0.58 directly gives p^c=0.62, which throws off the standard error to 0.0396 and z to 2.02.
Find the separate sample rates p^1 and p^2 for the observed gap on top of the z fraction, then pool all 800 plants to get p^c for the bottom.
The hypotheses are H0:p1−p2=0 (or p1=p2) and Ha:p1>p2. The sample proportions are p^1=200132=0.66 (66%) and p^2=600348=0.58 (58%), giving an observed gap of 0.66−0.58=0.08 (8%). The pooled proportion is:
p^c=200+600132+348=800480=0.60(60%)
(Watch out: averaging 0.66 and 0.58 directly gives p^c=0.62, which throws off the standard error to 0.0396 and z to 2.02.) Using p^c=0.60, the standard error and z-statistic are:
Standard Error=0.60×0.40×(2001+6001)=0.24×1501=0.0016=0.04(4%)
z=0.040.08−0=2.00
The observed 8% gap is 2 standard errors above zero, giving a one-sided p-value of 0.023. Since 0.023<0.05, we reject H0; 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% and a pooled standard error of 3.2%, giving z=−1.875. The area in a single tail beyond z=−1.875 is 0.030. State the p-value and the decision at α=0.05 if the original question before looking at the data was (a) one-sided, Ha:p1<p2, versus (b) two-sided, Ha:p1=p2, and explain in plain English what the two-sided 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<p2, the one-sided p-value is 0.030; since 0.030<0.05, we reject H0.
(b)For Ha:p1=p2, we count both tails (gaps at or beyond −6% and +6%), doubling the p-value to 2×0.030=0.060.(Watch out: forgetting to double the single-tail area leaves p=0.030 and leads to the wrong decision of rejecting H0.) Since 0.060>0.05, we fail to reject H0. In plain English, the two-sided p-value of 0.060 means that if the two software versions had the exact same true rate, there would be a 6% chance that random assignment alone would produce a gap of 6% or wider in either direction.
6
A sociologist takes two independent random samples, 500 adults who walk to work and 500 adults who drive to work, to test whether the two populations differ in the proportion reporting high daily energy (H0:p1=p2,Ha:p1=p2). Both groups have more than 100 successes and 100 failures, and the two-sample z-test gives z=2.60 with a two-sided p-value of 0.009. At α=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 and the independent random samples and 10-successes/10-failures conditions are met, the sociologist can reject H0 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 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.