01 / 20
\(\hat{p}_1\)
\(\hat{p}_2\)

\(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.

College Statistics

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?

\(\hat{p}_1\)
Sample proportion from Group 1: the fraction of successes observed in the first sample.
\(\hat{p}_2\)
Sample proportion from Group 2: the fraction of successes observed in the second sample.

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:

1
Medical trials: Does a new drug have a higher cure rate than a placebo?
2
Marketing: Do customers click more on Ad Design A vs. Ad Design B?
3
Education: Is the pass rate different for students who attended tutoring vs. those who did not?

Conditions for Validity

Before running the test, all four conditions must be verified. If any fails, the \(z\)-test may give unreliable results.

1
Random samples: Both samples are obtained randomly or through a randomized experiment.
2
Independence: The two groups are independent of each other, and individual observations within each group are independent.
3
10% condition: Each sample is less than 10% of its population: \(n_1 < 0.1N_1\) and \(n_2 < 0.1N_2\).
4
Large counts (success/failure): \(n_1\hat{p}_c \geq 10\), \(n_1(1-\hat{p}_c) \geq 10\), \(n_2\hat{p}_c \geq 10\), \(n_2(1-\hat{p}_c) \geq 10\), where \(\hat{p}_c\) is the pooled proportion.

Setting Up the Hypotheses

The null hypothesis always states no difference. The alternative depends on the research question.

Null \(H_0\)
\(p_1 - p_2 = 0\)
(equivalently, \(p_1 = p_2\))
Alternative \(H_a\)
\(p_1 - p_2 \neq 0\) (two-tailed)
\(p_1 - p_2 > 0\) (right-tailed)
\(p_1 - p_2 < 0\) (left-tailed)

The Pooled Proportion \(\hat{p}_c\)

$$\hat{p}_c = \frac{x_1 + x_2}{n_1 + n_2}$$

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

$$z = \frac{(\hat{p}_1 - \hat{p}_2) - 0}{\sqrt{\hat{p}_c(1-\hat{p}_c)\left(\dfrac{1}{n_1}+\dfrac{1}{n_2}\right)}}$$
Numerator
The observed difference \(\hat{p}_1 - \hat{p}_2\) minus the hypothesized difference (0 under \(H_0\)).
Denominator
The standard error of the difference, computed using the pooled proportion \(\hat{p}_c\).

Visualizing the \(p\)-Value

0
\(-z^*\)
\(+z^*\)
Reject Reject Fail to reject
Two-Tailed \(z\)-Test Rejection Regions

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

1
State hypotheses: Write \(H_0\!: p_1 - p_2 = 0\) and choose a one- or two-tailed \(H_a\).
2
Check conditions: Random, independent, 10% rule, and large counts using \(\hat{p}_c\).
3
Compute \(\hat{p}_c\): Pool: \(\hat{p}_c = \frac{x_1 + x_2}{n_1 + n_2}\).
4
Calculate SE and \(z\): Use the pooled SE formula in the denominator.
5
Find the \(p\)-value: Use the standard normal table or calculator.
6
Conclude: If \(p\text{-value} < \alpha\), reject \(H_0\). State the conclusion in context.

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.

Treatment
\(x_1 = 36\), \(n_1 = 200\)
\(\hat{p}_1 = 0.18\)
Placebo
\(x_2 = 18\), \(n_2 = 150\)
\(\hat{p}_2 = 0.12\)

Example 1: Computation

1
Pooled proportion: \(\hat{p}_c = \frac{36 + 18}{200 + 150} = \frac{54}{350} \approx 0.1543\)
2
Standard error: \(SE = \sqrt{0.1543 \times 0.8457 \times \left(\frac{1}{200}+\frac{1}{150}\right)} = \sqrt{0.1305 \times 0.01167} \approx 0.0390\)
3
Test statistic: \(z = \frac{0.18 - 0.12}{0.0390} = \frac{0.06}{0.0390} \approx 1.538\)
4
\(p\)-value: \(P(Z > 1.538) \approx 0.062\)

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.

Page A
\(\hat{p}_1 = \frac{84}{600} = 0.14\)
Page B
\(\hat{p}_2 = \frac{120}{600} = 0.20\)
Pooled
\(\hat{p}_c = \frac{204}{1200} = 0.17\)

Example 2: Solution

1
SE: \(\sqrt{0.17 \times 0.83 \times \left(\frac{1}{600}+\frac{1}{600}\right)} = \sqrt{0.1411 \times 0.003\overline{3}} \approx 0.02169\)
2
Test statistic: \(z = \frac{0.14 - 0.20}{0.02169} = \frac{-0.06}{0.02169} \approx -2.766\)
3
\(p\)-value (two-tailed): \(2 \times P(Z < -2.766) \approx 2 \times 0.0028 = 0.0057\)

Common Mistakes

✕ Using Unpooled SE
For a hypothesis test of \(p_1 = p_2\), you must pool. The unpooled SE is for confidence intervals only.
✕ Wrong Tail Direction
Choosing a two-tailed test when the problem says "greater than" or "less than." Read the claim carefully.
✕ Forgetting Large Counts
Skipping the check that \(n\hat{p}_c \geq 10\) and \(n(1-\hat{p}_c) \geq 10\) for both groups. The Normal approximation requires this.

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?