\(z\)-Test for
Difference of Proportions
Learn to test whether two population proportions are significantly different using the two-proportion \(z\)-test: hypotheses, pooled proportion, test statistic, and interpretation.
What Is the Two-Proportion \(z\)-Test?
When we collect data from two independent groups and observe a proportion of "successes" in each, we often want to know: is the difference between these proportions real, or could it be due to random chance?
When Do We Use It?
The two-proportion \(z\)-test applies when you compare categorical outcomes (success/failure) across two independent groups. Real-world examples include:
Conditions for Validity
Before running the test, all four conditions must be verified. If any fails, the \(z\)-test may give unreliable results.
Setting Up the Hypotheses
The null hypothesis always states no difference. The alternative depends on the research question.
(equivalently, \(p_1 = p_2\))
\(p_1 - p_2 > 0\) (right-tailed)
\(p_1 - p_2 < 0\) (left-tailed)
The Pooled Proportion \(\hat{p}_c\)
Here \(x_1\) and \(x_2\) are the number of successes in each sample, and \(n_1\) and \(n_2\) are the sample sizes. We combine all successes and all observations into one estimate because under \(H_0\) the proportions are equal.
The Test Statistic
Visualizing the \(p\)-Value
Pooled vs. Unpooled Standard Error
| Pooled (Hypothesis Test) | Unpooled (Confidence Interval) | |
|---|---|---|
| When? | Testing \(H_0\!: p_1 = p_2\) | Estimating \(p_1 - p_2\) |
| Assumes \(p_1 = p_2\)? | Yes | No |
| SE formula | \(\sqrt{\hat{p}_c(1-\hat{p}_c)\!\left(\frac{1}{n_1}+\frac{1}{n_2}\right)}\) | \(\sqrt{\frac{\hat{p}_1(1-\hat{p}_1)}{n_1}+\frac{\hat{p}_2(1-\hat{p}_2)}{n_2}}\) |
| Uses | \(\hat{p}_c\) (combined) | \(\hat{p}_1\) and \(\hat{p}_2\) separately |
How to Apply the Test
Example 1: Drug Trial
A pharmaceutical company tests a new drug. In the treatment group, 36 of 200 patients recovered. In the placebo group, 18 of 150 recovered. Test at \(\alpha = 0.05\) whether the drug has a higher recovery rate.
\(\hat{p}_1 = 0.18\)
\(\hat{p}_2 = 0.12\)
Example 1: Computation
Example 2: Click-Through Rates
A website runs an A/B test on two landing pages. Page A: 84 clicks out of 600 visitors. Page B: 120 clicks out of 600 visitors. Test at \(\alpha = 0.01\) whether the proportions differ.
Example 2: Solution
Common Mistakes
Question 1 of 5
In a two-proportion \(z\)-test with \(H_0\!: p_1 = p_2\), why do we use a pooled proportion \(\hat{p}_c\) to compute the standard error?
Question 2 of 5
A study finds \(\hat{p}_1 = 0.45\) (\(n_1 = 300\)) and \(\hat{p}_2 = 0.38\) (\(n_2 = 250\)). What is the pooled proportion \(\hat{p}_c\)?
Question 3 of 5
A two-proportion \(z\)-test yields \(z = -2.15\) for the hypotheses \(H_0\!: p_1 = p_2\) vs. \(H_a\!: p_1 \neq p_2\). What is the approximate \(p\)-value?
Question 4 of 5
Which of the following is a correct conclusion when \(p\text{-value} = 0.03\) and \(\alpha = 0.05\)?
Question 5 of 5
When constructing a confidence interval for \(p_1 - p_2\), we use the unpooled standard error. Why is this different from the hypothesis test?