COLLEGE STATISTICS • HYPOTHESIS TESTING

z-Test for Difference of Proportions — Hypothesis Test for Difference of Proportions

A formal statistical procedure for determining whether two population proportions differ significantly.

Historical Context & Motivation

The question of whether two groups differ in some categorical outcome—whether a new drug has a higher cure rate than a placebo, or whether voter turnout differs between two districts—has been central to statistical inquiry since the discipline's earliest days. The z-test for the difference of proportions emerged from a long tradition of applying the normal distribution to problems of inference about population parameters, a tradition rooted in the work of mathematicians and statisticians across the eighteenth, nineteenth, and twentieth centuries.

The foundations of this test lie in the Central Limit Theorem and the properties of the binomial distribution. As early as the 1730s, Abraham de Moivre showed that the binomial distribution could be approximated by the normal curve when sample sizes were sufficiently large. This insight would eventually underpin every large-sample proportion test used in modern statistics. The formalization of hypothesis testing itself, however, required the contributions of several key figures over the next two centuries.

1733
De Moivre's Normal Approximation
Abraham de Moivre demonstrated that the binomial distribution approaches the normal distribution for large sample sizes, laying the mathematical groundwork for all large-sample z-tests on proportions.
1812
Laplace's Théorie Analytique
Pierre-Simon Laplace rigorously proved the Central Limit Theorem and extended the normal approximation framework, providing the theoretical justification for using z-statistics when comparing sample proportions.
1900
Pearson's Chi-Squared Test
Karl Pearson introduced the chi-squared goodness-of-fit test. For 2 × 2 contingency tables, the chi-squared statistic is mathematically equivalent to the square of the z-statistic for comparing two proportions.
1928
Neyman–Pearson Framework
Jerzy Neyman and Egon Pearson formalized the concepts of null and alternative hypotheses, Type I and Type II errors, and statistical power, providing the decision-theoretic structure within which the two-proportion z-test is applied today.
1950s–
Modern Applications
The two-proportion z-test became a standard tool in clinical trials, A/B testing in marketing, quality control in manufacturing, and social science research, supported by the widespread availability of statistical tables and later by software.

The central question addressed by this test is deceptively simple: given two independent samples from two populations, is the observed difference between the sample proportions large enough to conclude that the population proportions genuinely differ, or could such a difference easily arise from random sampling variability alone? This question appears constantly across disciplines—from medicine to marketing to political science—making the two-proportion z-test one of the most widely used inferential procedures in applied statistics.

Core Principles & Definitions

Before constructing the test, it is essential to understand the foundational concepts that govern its logic and validity. The z-test for the difference of proportions rests on the same inferential architecture as all classical hypothesis tests: we assume a null hypothesis is true, compute the probability of observing data as extreme as ours under that assumption, and make a decision accordingly. The following principles define the specific conditions and components of this particular test.

1

Population Proportion (p)

The true fraction of individuals in a population possessing a characteristic of interest. We denote the proportions for two populations as p₁ and p₂. These are unknown parameters that we wish to compare.
2

Sample Proportion (p̂)

The observed fraction of successes in a sample: p̂ = x / n, where x is the number of successes and n is the sample size. Each sample provides p̂₁ and p̂₂ as point estimates of p₁ and p₂.
3

Null & Alternative Hypotheses

The null hypothesis (H₀) typically states p₁ − p₂ = 0 (no difference). The alternative hypothesis (Hₐ) asserts the proportions differ—either two-sided (p₁ ≠ p₂) or one-sided (p₁ > p₂ or p₁ < p₂).
4

Pooled Proportion (p̂ₚ)

Under H₀: p₁ = p₂, we estimate the common proportion by pooling both samples: p̂ₚ = (x₁ + x₂) / (n₁ + n₂). This pooled estimate is used in the standard error calculation because H₀ assumes one shared proportion.
5

Conditions for Validity

The test requires: (1) independent random samples from two populations, (2) large enough samples so that n₁p̂ₚ, n₁(1 − p̂ₚ), n₂p̂ₚ, and n₂(1 − p̂ₚ) are each ≥ 5 (preferably ≥ 10), and (3) each sample is no more than 10% of its population.
KEY TAKEAWAY
Think of the z-test for two proportions like comparing the hit rates of two baseball players across a full season. If Player A bats .310 and Player B bats .290, the raw difference is 0.020—but is that meaningful or just noise? The z-test accounts for how many at-bats each player had (sample size), combines their overall hit rate under the assumption they are equally skilled (pooled proportion), and then asks: how surprised should we be to see a .020 gap if they truly hit at the same rate? A large z-score means the gap is hard to explain by chance alone.

Visual Explanation

The logic of the two-proportion z-test is best understood visually through the sampling distribution of the difference in sample proportions under the null hypothesis. When H₀ is true and both populations share a common proportion, the distribution of p̂₁ − p̂₂ is centered at zero and is approximately normal for large samples. The observed difference is then located on this distribution, and the z-score quantifies how many standard errors it lies from zero.

The bell curve represents the sampling distribution of the difference p̂₁ − p̂₂ when H₀ (p₁ = p₂) is true, centered at zero. The red shaded regions are the rejection regions in the tails beyond ±z*. The amber dashed line marks an observed sample difference; its position relative to the critical values determines the test decision.

In the diagram above, the key insight is that the entire curve assumes H₀ is true. The spread of the curve (its standard error) depends on the pooled proportion and the two sample sizes. A larger z-score pushes the observed difference further into the tails, making it increasingly implausible that H₀ is correct. When the observed difference falls in the rejection region, we conclude that the evidence is strong enough to reject the null hypothesis at the chosen significance level α.

Mathematical Framework

The mathematical construction of the two-proportion z-test proceeds naturally from the sampling distribution of the difference between two independent sample proportions. Under the null hypothesis H₀: p₁ = p₂ = p, the difference p̂₁ − p̂₂ has an approximately normal distribution centered at zero, with a standard error determined by the common proportion and the two sample sizes.

HYPOTHESES
H₀: p₁ − p₂ = 0 vs. Hₐ: p₁ − p₂ ≠ 0 (two-sided)
For one-sided tests, the alternative is either p₁ − p₂ > 0 or p₁ − p₂ < 0, depending on the research question. The null always asserts no difference.
POOLED PROPORTION
p̂ₚ = (x₁ + x₂) / (n₁ + n₂)
Where x₁ and x₂ are the numbers of successes in samples 1 and 2, and n₁ and n₂ are the respective sample sizes. The pooled proportion estimates the common population proportion under H₀.
STANDARD ERROR (POOLED)
SE = √[ p̂ₚ(1 − p̂ₚ)(1/n₁ + 1/n₂) ]
This pooled standard error measures the expected variability in the sampling distribution of p̂₁ − p̂₂ when both populations share the same proportion. The term (1/n₁ + 1/n₂) reflects the combined sampling uncertainty from both groups.
Z-STATISTIC
z = (p̂₁ − p̂₂) / √[ p̂ₚ(1 − p̂ₚ)(1/n₁ + 1/n₂) ]
The z-statistic measures how many standard errors the observed difference p̂₁ − p̂₂ lies from the hypothesized difference of zero. Under H₀ and for sufficiently large samples, z follows a standard normal distribution N(0, 1). Compare |z| to the critical value z* (e.g., 1.96 for α = 0.05 two-sided) or compute the p-value from z.
📐 Decision Rule
For a two-sided test at significance level α: reject H₀ if |z| ≥ zα/2. Equivalently, reject H₀ if the p-value ≤ α. Common critical values: z* = 1.645 (α = 0.10), z* = 1.960 (α = 0.05), z* = 2.576 (α = 0.01).

Step-by-Step Procedure & Conditions

Executing a two-proportion z-test follows a systematic sequence of steps. Before performing any calculations, you must verify that the conditions for the normal approximation are satisfied. Then you state hypotheses, compute the test statistic, find the p-value, and draw a conclusion. The following diagram illustrates this procedure as a structured flowchart.

The flowchart shows the complete procedure for a two-proportion z-test: verify conditions, state hypotheses, compute the pooled proportion, calculate the z-statistic, obtain the p-value, and compare it to the significance level α to reach a conclusion.

Checking Conditions in Detail

  • Independence: The two samples must be drawn independently of each other, and observations within each sample must be independent. Random sampling or random assignment satisfies this condition. If sampling without replacement, each sample should be no more than 10% of its respective population.
  • Normality (Large Sample): The sampling distribution of p̂₁ − p̂₂ must be approximately normal. This holds when n₁p̂ₚ ≥ 5, n₁(1 − p̂ₚ) ≥ 5, n₂p̂ₚ ≥ 5, and n₂(1 − p̂ₚ) ≥ 5. Some textbooks use 10 as the threshold for a more conservative check.
  • Random Sampling: Each sample must be obtained via a random mechanism (simple random sample, stratified random sample, etc.) or arise from random assignment in an experiment. Convenience samples invalidate the inferential framework.

Worked Example

A pharmaceutical company is testing a new medication to reduce the incidence of headaches. In a randomized controlled trial, 500 patients received the new drug and 400 received a placebo. Among those who received the drug, 120 reported headaches within 24 hours; among those who received the placebo, 130 reported headaches. At the α = 0.05 significance level, is there evidence that the drug lowers the headache rate compared to the placebo?

Two-Proportion z-Test: Drug vs. Placebo Headache Rates
1
Step 1 — Identify Given ValuesDrug group: x₁ = 120 headaches, n₁ = 500. Placebo group: x₂ = 130 headaches, n₂ = 400. Sample proportions: p̂₁ = 120/500 = 0.240, p̂₂ = 130/400 = 0.325. Significance level: α = 0.05.
p̂₁ = 0.240, p̂₂ = 0.325
2
Step 2 — State HypothesesBecause we want to test whether the drug lowers the headache rate, we use a one-sided test. Let p₁ = drug headache rate and p₂ = placebo headache rate. H₀: p₁ = p₂ (no difference). Hₐ: p₁ < p₂ (drug reduces headaches). This is a left-tailed test.
H₀: p₁ = p₂, Hₐ: p₁ < p₂
3
Step 3 — Compute Pooled Proportionp̂ₚ = (x₁ + x₂) / (n₁ + n₂) = (120 + 130) / (500 + 400) = 250 / 900 ≈ 0.2778.
p̂ₚ ≈ 0.2778
4
Step 4 — Check ConditionsIndependence: patients were randomly assigned to groups. Normality check: n₁p̂ₚ = 500 × 0.2778 = 138.9 ≥ 5 ✓, n₁(1 − p̂ₚ) = 500 × 0.7222 = 361.1 ≥ 5 ✓, n₂p̂ₚ = 400 × 0.2778 = 111.1 ≥ 5 ✓, n₂(1 − p̂ₚ) = 400 × 0.7222 = 288.9 ≥ 5 ✓. All conditions satisfied.
All conditions met ✓
5
Step 5 — Calculate Standard ErrorSE = √[ p̂ₚ(1 − p̂ₚ)(1/n₁ + 1/n₂) ] = √[ 0.2778 × 0.7222 × (1/500 + 1/400) ] = √[ 0.2006 × (0.002 + 0.0025) ] = √[ 0.2006 × 0.0045 ] = √[ 0.000903 ] ≈ 0.03005.
SE ≈ 0.03005
6
Step 6 — Compute z-Statisticz = (p̂₁ − p̂₂) / SE = (0.240 − 0.325) / 0.03005 = −0.085 / 0.03005 ≈ −2.83.
z ≈ −2.83
7
Step 7 — Find p-value and ConcludeFor a left-tailed test, the p-value is P(Z ≤ −2.83). Using a standard normal table or software, P(Z ≤ −2.83) ≈ 0.0023. Since 0.0023 < 0.05 = α, we reject H₀. There is statistically significant evidence at the 5% level that the new drug produces a lower headache rate than the placebo. The sample data suggest the drug reduces the headache proportion by about 8.5 percentage points.
p-value ≈ 0.0023; Reject H₀

Strengths, Limitations & Comparisons

Like all statistical procedures, the two-proportion z-test has both advantages and constraints. Understanding these helps you decide when this test is appropriate and when an alternative method might serve better.

Strengths and limitations of the two-proportion z-test
AspectStrengthsLimitations
SimplicityStraightforward computation requiring only counts and sample sizes. Easy to implement by hand or in any software package.Requires large samples for the normal approximation to be valid. With small samples or extreme proportions, the approximation is poor.
InterpretabilityThe z-score and p-value have familiar, well-understood interpretations. Easy to communicate results to non-statisticians.Statistical significance (small p-value) does not imply practical significance. A very large sample can detect trivially small differences.
FlexibilitySupports one-sided and two-sided alternatives. Can be extended to confidence intervals for p₁ − p₂.Assumes independent samples. Cannot be used for paired or matched data (e.g., before/after on the same subjects).
ScopeDirectly addresses the research question of whether two proportions differ, which arises ubiquitously across disciplines.Limited to comparing exactly two groups. For three or more proportions, chi-squared tests or logistic regression are needed.
⚠️ PRACTICAL SIGNIFICANCE MATTERS
Always pair hypothesis testing with an effect size measure or confidence interval. A z-test might reject H₀ with p < 0.001 for a difference of 0.5 percentage points if both samples have n = 50,000. The difference is statistically significant but practically negligible. Reporting the confidence interval for p₁ − p₂ gives your audience the information needed to assess whether the observed difference is large enough to be meaningful in context.

Connection to Advanced Methods

The two-proportion z-test occupies a foundational position within a family of related inferential procedures. Understanding its connections to more advanced methods clarifies both its role and its limitations. The following table situates the z-test alongside the methods it connects to as your statistical toolkit expands.

The two-proportion z-test compared to advanced methods
Featurez-Test (Two Proportions)Advanced Alternatives
Number of GroupsExactly 2 independent groupsChi-squared test of homogeneity handles 3+ groups simultaneously
Sample SizeRequires large samples (normal approximation)Fisher's exact test works for any sample size, including very small counts
Confounding VariablesCannot adjust for covariatesLogistic regression models the log-odds of success while controlling for multiple predictors
Effect MeasureDifference in proportions (p₁ − p₂)Odds ratios and relative risks provide alternative effect size measures via logistic or log-binomial regression
Relationship to χ²z² is exactly equal to the χ² statistic for a 2×2 tableChi-squared generalizes to r × c tables and goodness-of-fit applications

A particularly elegant connection is the algebraic equivalence between the two-proportion z-test and the chi-squared test for a 2 × 2 contingency table: the chi-squared statistic χ² is exactly equal to z². This means the two tests always yield the same p-value for a two-sided test. The z-test, however, has the advantage of naturally accommodating one-sided alternatives, which the chi-squared test does not directly support. As you advance into multivariate analysis, logistic regression will subsume and extend the z-test by allowing you to compare proportions while simultaneously adjusting for confounders—an essential capability in observational studies.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why the two-proportion z-test uses a pooled proportion p̂ₚ rather than computing separate standard errors for each sample when testing H₀: p₁ = p₂. What assumption justifies pooling, and what would happen conceptually if we did not pool?
PROBLEM 2BASIC CALCULATION
In a survey, 84 out of 300 college students in City A support a particular policy, while 60 out of 250 students in City B support it. Compute the pooled proportion p̂ₚ, the standard error, and the z-statistic for testing H₀: p₁ = p₂ vs. Hₐ: p₁ ≠ p₂.
PROBLEM 3INTERMEDIATE
A website conducts an A/B test. Version A was shown to 1,200 visitors and 180 made a purchase; Version B was shown to 1,000 visitors and 170 made a purchase. At α = 0.05, test whether Version B has a higher conversion rate than Version A. State your hypotheses, check the normality condition, compute the test statistic, find the p-value, and state your conclusion.
PROBLEM 4APPLIED
A public health researcher compares vaccination rates in two counties. In County X, 612 out of 800 randomly selected adults are vaccinated; in County Y, 495 out of 700 are vaccinated. Conduct a two-sided test at α = 0.01 to determine whether the vaccination rates differ. Also construct a 99% confidence interval for p₁ − p₂ (using the unpooled standard error for the confidence interval) and interpret both results.
PROBLEM 5CRITICAL THINKING
A colleague performs a two-proportion z-test and obtains z = 2.05 with p-value = 0.040. They conclude that the effect is "practically meaningful." Critique this conclusion. Under what circumstances could a statistically significant result (p < 0.05) correspond to a difference that has no practical importance? Propose a complementary analysis the colleague should perform and explain how it addresses the limitations of the z-test alone.

Lesson Summary

The z-test for the difference of proportions is a large-sample hypothesis test used to determine whether two population proportions p₁ and p₂ differ significantly. Under the null hypothesis H₀: p₁ = p₂, the two samples are combined to form a pooled proportion p̂ₚ = (x₁ + x₂)/(n₁ + n₂), which estimates the common population proportion. The z-statistic z = (p̂₁ − p̂₂) / √[p̂ₚ(1 − p̂ₚ)(1/n₁ + 1/n₂)] measures how many standard errors the observed difference lies from zero and is compared to the standard normal distribution to obtain a p-value.

Validity requires independent random samples and sufficiently large counts so that the normal approximation holds (n₁p̂ₚ, n₁(1−p̂ₚ), n₂p̂ₚ, n₂(1−p̂ₚ) each ≥ 5). A statistically significant result should always be accompanied by a confidence interval for p₁ − p₂ and a discussion of practical significance. For small samples, consider Fisher's exact test; for multiple groups, use the chi-squared test; and for adjusting for covariates, transition to logistic regression.

Varsity Tutors • College Statistics • z-Test for Difference of Proportions