| Standard deviation of p̂₁ − p̂₂ | |
|---|---|
| Confidence interval | |
| Test statistic, pooled |
Lesson
The theory — Inference for Two Proportions
Inference for two proportions compares p₁ and p₂, the success rates of two populations or two treatments, through the difference p̂₁ − p̂₂: a confidence interval estimates p₁ − p₂, and a significance test judges H₀: p₁ = p₂.
Where the formula comes from
- The sampling distribution of p̂₁ − p̂₂. Over repeated independent samples, p̂₁ − p̂₂ has mean p₁ − p₂. Because the samples are independent, their variances add, so the standard deviations combine under a square root and never by plain addition. The shape is close to normal when n₁p₁, n₁(1 − p₁), n₂p₂ and n₂(1 − p₂) are all at least 10.
- Check the conditions. Random: two independent random samples, or two groups formed by random assignment in an experiment. 10%: when sampling without replacement, each sample is at most a tenth of its population; with random assignment there is no population to sample from and the condition does not apply. Large counts: for an interval, at least 10 successes and 10 failures in each group; for a test, the four expected counts from the pooled proportion.
- The interval. (p̂₁ − p̂₂) ± z* times the standard error, with each group’s own p̂ inside it, because the interval assumes nothing about p₁ and p₂. If it contains 0, no difference is a plausible value; if it lies wholly above or below 0, it is convincing evidence of a difference in that direction.
- The test. State H₀: p₁ = p₂ and the alternative. If H₀ is true the two samples estimate one proportion, so the test pools them into p̂c and computes the standard deviation of p̂₁ − p̂₂ from p̂c alone. z is the observed difference measured in that standard deviation, and the p-value is the chance, if H₀ is true, of a difference at least that far in the direction of Hₐ.
- Conclude, and say what the design allows. Compare the p-value with α and conclude in context, as for one proportion. Then the scope: random assignment lets you conclude that the treatment caused the difference, and random sampling lets you generalise to the populations sampled. Two random samples in an observational study can show that two populations differ; they cannot show why.
- Assumes
- The normal model approximates two binomial counts. When large counts fail, the page prints Fisher’s exact p-value: it takes the total number of successes as fixed and asks how often a random split of the n₁ + n₂ subjects would put at least x₁ of them in group 1. Its two-sided version doubles the smaller tail.
Problems solved in full
-
The sampling distribution of p̂₁ − p̂₂ 3 steps
In a large town, 30% of adults and 20% of teenagers say they read a newspaper. Independent random samples of 100 adults and 150 teenagers are taken. Describe the sampling distribution of p̂₁ − p̂₂, and find how likely it is that the adults’ sample proportion comes out smaller than the teenagers’.
-
Its centre and spread follow from the two proportions and the two sample sizes:
-
Its shape is approximately normal, because all four expected counts reach 10:
-
The adults’ proportion is the smaller one when p̂₁ − p̂₂ falls below 0:
Answer
Approximately normal, with mean 0.1 and standard deviation 0.0563. The chance that the adults’ sample proportion is the smaller is about 0.038.
-
-
Constructing a confidence interval 3 steps
In a random sample of 300 adults in one city, 168 back a ban on cars in the city centre; in a random sample of 350 adults in a second city, 140 do. Construct and interpret a 95% confidence interval for the difference between the two cities’ proportions.
Show solution
-
Conditions: two independent random samples; a city has far more than the 3,000 and 3,500 adults that would make each sample a tenth of its population; 168, 132, 140 and 210 are all at least 10. The two proportions:
-
The standard error, with each city’s own proportion:
-
Multiply by z* = 1.96 and add and subtract:
Answer
(0.084, 0.236). We are 95% confident that the proportion of adults who back the ban is between 8.4 and 23.6 percentage points higher in the first city than in the second.
-
-
Using an interval to judge a claim 2 steps
In random samples of customers, 45 of 150 at store A and 52 of 200 at store B returned an item. The manager claims the two stores’ return rates differ. Use a 95% confidence interval to judge the claim.
Show solution
-
The difference and its standard error:
-
The interval, and where 0 lies:
Answer
The interval (−0.055, 0.135) contains 0, so no difference is a plausible value: the data do not give convincing evidence that the return rates differ.
-
-
A two-sided test in an experiment 3 steps
200 volunteers were split at random into two groups of 100. One group was sent a text reminder; 62 of them got a flu shot, against 45 of the other group. Test at the 5% level whether the reminder makes a difference, and say what the conclusion allows and which error it risks.
Show solution
-
Hypotheses: H₀: p₁ = p₂, Hₐ: p₁ ≠ p₂. Conditions: random assignment; the expected counts 53.5 and 46.5 in each group are at least 10. If H₀ is true the groups share one proportion:
-
The test statistic, with the standard deviation from the pooled proportion:
-
The two-sided p-value:
Answer
p = 0.016 < 0.05, so reject H₀: there is convincing evidence that the reminder changes the proportion who get a flu shot. The groups were formed by random assignment, so the reminder caused the difference; they were volunteers, so the conclusion reaches people like them. If the reminder in fact makes no difference, this conclusion is a Type I error.
-
-
A one-sided test on observational data 3 steps
A school district has 2,600 students who play a musical instrument and 7,400 who do not. Random samples of 200 players and 180 non-players are taken. 26 of the first group and 18 of the second are on the honour roll. Is there convincing evidence, at α = 0.05, that a higher proportion of instrument players are on the honour roll?
Show solution
-
Hypotheses: H₀: p₁ = p₂, Hₐ: p₁ > p₂. Conditions: two independent random samples; 200 is less than a tenth of 2,600 and 180 less than a tenth of 7,400; expected counts 23.2, 176.8, 20.8 and 159.2. The pooled proportion:
-
The test statistic:
-
The one-sided p-value:
Answer
p = 0.181 ≥ 0.05, so fail to reject H₀: there is not convincing evidence that instrument players are more often on the honour roll. Even a small p-value would not have shown that playing an instrument raises grades: these are two samples observed, not groups assigned.
-
-
When large counts fail: Fisher’s exact test 2 steps
In a pilot study, 20 patients were assigned at random, 10 to a new drug and 10 to a placebo. 5 on the drug improved and 1 on the placebo did. Is the z-test appropriate? Find the exact p-value for Hₐ: p₁ > p₂.
Show solution
-
Large counts for the test fail:
-
If the drug does nothing, the 6 patients who improved would have improved anyway, and the random assignment alone decided how many of them landed in the drug group. The chance that it put 5 or 6 of them there:
Answer
No: each group’s expected counts are 3 and 7. The exact p-value is 0.070, against 0.025 from the normal curve, so the pilot is not convincing evidence at the 5% level.
-
Supplementary problems, answers only
-
For the two cities’ 168 of 300 and 140 of 350, find a 90% confidence interval for the difference in proportions.
Show answer
(0.096, 0.224)
-
Redo the flu-shot test, 62 of 100 against 45 of 100, at α = 0.01. What is the decision, and which error could it be?
Show answer
p = 0.016 ≥ 0.01: fail to reject H₀. If the reminder really does make a difference, this is a Type II error.
-
Why does the test pool the two samples while the interval does not?
Show answer
The test is computed as if H₀ were true, and under H₀ both samples estimate the same proportion, so combining them gives the best estimate of it. The interval estimates p₁ − p₂ without assuming the two are equal, so each group keeps its own p̂.
-
Using z ≈ (a − b)/√(a + b), estimate z for the vaccine trial’s 8 cases against 162.
Show answer
z ≈ −11.8
-
A 95% confidence interval for p₁ − p₂ is (−0.12, −0.03). What does it say about the two proportions?
Show answer
0 is not in it, so there is convincing evidence that p₁ is smaller than p₂, by somewhere between 3 and 12 percentage points.
-
Random samples of 400 smokers and 400 non-smokers show a much higher proportion of coughs among smokers, with p < 0.0001. Does the study show that smoking causes coughing?
Show answer
Not on its own: it is an observational study, so it shows that the two populations differ, and a lurking variable could account for the difference. Only random assignment would let it show cause, and assigning people to smoke would be unethical.
-
For 40 of 100 against 27 of 100, the chi-square statistic of the 2 × 2 table is 3.793. Find the z-statistic of the two-proportion test without its formula.
Show answer
z = √3.793 ≈ 1.95, positive because p̂₁ = 0.4 is the larger proportion
Learning path
Statistics: from data to proportions
References (2)
- Insight block 3 and the vaccine preset: 21,720 people received the BNT162b2 vaccine and 21,728 a placebo, and 8 cases of Covid-19 were counted in the first group against 162 in the second, at least 7 days after the second dose: Polack, F. P., Thomas, S. J., Kitchin, N. et al. (2020). Safety and efficacy of the BNT162b2 mRNA Covid-19 vaccine. New England Journal of Medicine, 383(27), 2603–2615.
- Fisher's exact test, which the page prints beside the z-test: it conditions on both margins of the 2 × 2 table, so the count in one cell is hypergeometric, and a large-sample approximation is unnecessary when the exact distribution can be computed: Agresti, A. (1992). A survey of exact inference for contingency tables. Statistical Science, 7(1), 131–153.