Confidence Interval for a Difference in Proportions
When we compare two groups, we want to know how much higher one group's true proportion is than the other's, and capture that true difference inside a confidence interval.
1
Why a Difference Needs a Margin of Error
Suppose a hospital tests a new cold medicine against a sugar-pill placebo to see what proportion of patients recover within three days:
Group A (Medicine):60 out of 100 patients recover (60%=0.60).
Group B (Placebo):80 out of 200 patients recover (40%=0.40).
We want to estimate the true gap between the medicine recovery rate and the placebo recovery rate.
Why a Difference Needs a Margin of Error
Subtracting the two sample proportions gives our best guess for the true gap (60%−40%=20%). Because both sample percentages would wobble in a new study, that 20% gap needs a margin of error around it.
2
Finding the Standard Error of the Difference
To build a margin of error, we first need the Standard Error of the difference: how much the gap between the two sample proportions typically wobbles from study to study.
For a single group, we already know that its variance (its squared wobble) comes from multiplying the Yes proportion by the No proportion and dividing by the group's sample size:
Variance of one group=nYes×No
Now let's see how the two individual wobbles combine when we look at the gap between two groups.
Finding the Standard Error of the Difference
Text solution
Group A's variance (Medicine)Multiply the Yes and No proportions for the 100 patients in the medicine group and divide by 100.
VarianceA=1000.60×0.40=0.0024
Group B's variance (Placebo)Multiply the Yes and No proportions for the 200 patients in the placebo group and divide by 200, where having twice as many people cuts the variance in half.
VarianceB=2000.40×0.60=0.0012
Add the variances under one square rootAdd both groups' variances together and take the square root to bring the combined wobble back to a standard percentage.
So if we repeated this study over and over, the sample gap between the medicine and the placebo would typically bounce around by about 6%.
See how changing each group's sample size changes its individual wobble and the combined Standard Error for the gap:
Testing more people shrinks a group's standard error, and because both groups' variances add together, the gap's standard error is always wider than either group's alone.
3
Building the 95% Confidence Interval
Now we want to combine our best guess (20%) and our Standard Error (6%) to build a 95% confidence interval for the true difference in recovery rates.
Just like with a single proportion, capturing the central 95% of a normal bell curve means stepping out 1.96 standard errors in both directions from our best guess.
Building the 95% Confidence Interval
Text solution
Multiply by 1.96 for the 95% Margin of ErrorStep out 1.96 standard errors to find how far our interval reaches in each direction.
Margin of Error=1.96×6%=11.76%
Subtract and add the Margin of Error around the gapCenter the interval at our 20% best guess and step down and up by 11.76%.
We are 95% confident that the true recovery rate for the medicine is between 8.24 and 31.76 percentage points higher than for the placebo (roughly 8 to 32 percentage points).
4
Looking for Zero in the Interval
Once we have the confidence interval, we want to know whether it gives convincing evidence that the medicine actually beats the placebo, or whether the gap we saw could just be random luck.
Looking for Zero in the Interval
Because we subtracted Medicine−Placebo, the sign of each number tells us which group is ahead:
Positive numbers mean the Medicine has the higher recovery rate.
Negative numbers (like −4%) do not mean a negative percentage of people recovered. They mean the Placebo beat the Medicine by 4 percentage points.
Zero (0%) means the two treatments have the exact same recovery rate.
Try changing the Medicine recovery rate against the Placebo's 40% rate to see when the 95% confidence interval crosses 0% and when it stays completely to one side:
A difference between the two bars is convincing only when the whole confidence interval stays clear of 0%, since crossing 0% means no real difference is still a believable answer.
5
Conditions for a Two-Proportion Interval
Before we can trust the 1.96 normal bell-curve value, we need to check the three conditions that make sure our sampling distribution is centered at the true difference, has the right spread, and is bell-shaped. How we check them depends on whether the data came from a randomized experiment or two separate random samples.
Conditions for a Two-Proportion Interval
In our cold medicine experiment, patients were randomly assigned to the two independent groups, and all four Yes and No counts are at least 10:
Group A: Group B: 60 Yes,40 No≥1080 Yes,120 No≥10
See what happens to the shape of the sampling distribution when Group A's Yes or No count drops below 10 and pushes Group A too close to 0% or 100%:
The bell curve for the difference stays symmetric as long as all four Yes and No counts are at least 10, because dropping below 10 pushes that group against the 0% or 100% wall and squishes the curve.
6
The Two-Proportion Confidence Interval Formula
We can write the entire method, starting with the sample gap, adding both variances under a single square root, and stepping out z∗ standard errors, as one compact formula.
The Two-Proportion Confidence Interval Formula
(p^1−p^2)±z∗
n1p^1(1−p^1)+n2p^2(1−p^2)
best guessfor the gap(p^1−p^2)±how many wobblesout each wayz∗Standard Error of the differenceGroup 1 variancen1p^1(1−p^1)+Group 2 variancen2p^2(1−p^2)
Here, p^1 and p^2 are the two sample "Yes" proportions, while 1−p^1 and 1−p^2 are their "No" proportions. On a test, writing out this setup with your numbers plugged in shows your full method before you even touch a calculator.
Key concepts
Use a two-proportion confidence interval whenever you want to estimate the gap between two independent groups' Yes/No proportions, such as comparing a medicine (p^1=0.60 out of n1=100) against a placebo (p^2=0.40 out of n2=200). (If you only have one sample and are comparing it to a fixed number, like testing whether a single group's 60% rate differs from a known 50% national rate, only one group wobbles, so use a one-proportion interval instead.)
Before computing, check the conditions on both groups:
Random and Independent
Both groups must come from random assignment or independent random samples. When sampling without replacement, both samples must be under 10% of their populations (skip the 10% check in a randomized experiment).
Large Counts
All four Yes and No counts must be at least 10 (60,40≥10 and 80,120≥10).
Then build and interpret the interval in four steps:
Best guess
Subtract the sample proportions (0.60−0.40=0.20).
Standard Error
Add the two variances under one square root (1000.60×0.40+2000.40×0.60=0.06).
Interval
Step out z∗ standard errors from the best guess (20%±1.96×6%, giving 8.24% to 31.76%).
Look for 0%
Keep your subtraction order (Group 1−Group 2) in mind so you know that negative values mean Group 2 is higher. An interval crossing 0% (like −4% to +44%) means zero real difference is a believable value, while an interval completely on one side of 0% gives convincing evidence that one group beats the other.
7
Practice
1
In a study comparing two physical therapy routines, 160 out of 200 patients in Group A recovered within a month, compared to 180 out of 300 patients in Group B. Find the best guess for the difference in recovery rates (Group A minus Group B), the Standard Error of the difference, the 95% Margin of Error, and the 95% confidence interval.
Start by turning each group's recoveries into a sample proportion (p^A and p^B). Once you have each group's Yes and No proportions, how do you combine their two variances under the square root?
Group A's sample proportion is 200160=0.80 (80%) and Group B's is 300180=0.60 (60%), so the best guess for the difference is:
Best guess=80%−60%=20% (or 0.20)
Group A's variance is 2000.80×0.20=0.0008 and Group B's variance is 3000.60×0.40=0.0008. (Be careful not to take the square root of each variance separately and add the two standard errors: 0.0008+0.0008≈5.66%, which leads to a too-wide interval of 8.91% to 31.09%.) Adding the variances under one square root gives:
Standard Error=0.0008+0.0008=0.0016=0.04=4%
For 95% confidence, step out 1.96 standard errors:
Margin of Error=1.96×4%=7.84%95% Confidence Interval=20%±7.84%=12.16% to 27.84%
2
A researcher compares two groups where Group A (100 people, 70% Yes) has a variance of 1000.70×0.30=0.0021 and Group B (160 people, 40% Yes) has a variance of 1600.40×0.60=0.0015. Because she is estimating the difference (Group A minus Group B), she subtracts the variances to get 0.0021−0.0015≈2.45% for the Standard Error. Explain why subtracting the variances is wrong and find the correct Standard Error.
Variances always add even when subtracting proportions (and don't forget to take the square root after adding, or you will get the combined variance 0.0036=0.36% instead of the Standard Error).
Both sample proportions bounce around on their own. If one group randomly bounces higher at the exact moment the other dips lower, what happens to the gap between them?
Subtracting two sample proportions never cancels out their wobble; having two wobbling groups always creates more uncertainty because one group can randomly bounce higher at the exact moment the other dips lower. Variances always add even when subtracting proportions (and don't forget to take the square root after adding, or you will get the combined variance 0.0036=0.36% instead of the Standard Error):
Standard Error=0.0021+0.0015=0.0036=0.06=6%
3
A teacher compares a new study app to paper flashcards by calculating (App pass rate−Flashcard pass rate) and finds a 95% confidence interval from −6% to +18%. What does the −6% endpoint mean in this context, and does the interval provide convincing evidence that the study app works better than flashcards?
Check the subtraction order (App−Flashcards): what has to be true about the two pass rates for that subtraction to come out negative, and where does 0% sit relative to −6% and +18%?
Because the subtraction order is App−Flashcards, a negative number like −6% means the flashcard pass rate is 6 percentage points higher than the app pass rate (don't misread −6% as the app's pass rate dropping by 6%). Also, avoid looking only at the positive +18% upper endpoint and concluding the app wins: because 0% (no difference at all between the app and flashcards) sits inside the range of believable values from −6% to +18%, the interval does not provide convincing evidence that the study app works better than flashcards.
4
Study 1 takes 300 patients from a small clinic of 2,000 patients and randomly assigns 150 to a new allergy pill and 150 to a placebo. Study 2 takes two separate random samples of 150 seniors from High School A (which has 1,200 seniors) and 150 seniors from High School B (which has 2,000 seniors) to compare how many walk to school. Which study violates the 10% condition, and why is the other study fine even though 300 is more than 10% of 2,000?
First ask whether each study is sampling from a population or randomly assigning volunteers in an experiment; when you do sample from two populations, do you check the 10% condition on the combined total or on each school separately?
Study 1 is fine because it is a randomized experiment using random assignment rather than sampling from a population, so the 10% condition does not apply (a common mistake is checking 2,000300=15%>10% and wrongly disqualifying Study 1). In Study 2, when sampling without replacement from two populations, both samples must be less than 10% of their own populations (don't combine the two schools to get 3,200300=9.375%<10%): 150 is less than 10% of High School B's 2,000 seniors (200), but 150 is more than 10% of High School A's 1,200 seniors (120), so Study 2 violates the 10% condition.
5
To compare defect rates between two factories, inspectors take independent random samples of 200 items from Factory A and 200 items from Factory B (each less than 10% of that factory's output). In Factory A, 193 items pass inspection; in Factory B, 170 items pass inspection. Explain why it is not safe to use the 1.96 normal bell-curve value to build a confidence interval for the difference here.
Don't stop after checking the pass counts: write out all four counts (passes and failures in both factories) and compare each one against 10.
The Large Counts condition requires all four counts (passes and failures in both groups) to be at least 10. Watch out for checking only the sample sizes (200≥10) or only the pass counts (193≥10 and 170≥10) and assuming the condition passes. While Factory B has 170 passes and 30 failures and Factory A has 193 passes, Factory A has only 200−193=7 failures, which is less than 10. That puts Factory A's 96.5% pass rate too close to 100%, squishing the sampling distribution into a lopsided shape instead of a symmetric normal bell curve.