Tutorials › Introduction to Statistics › Setting up a Two-Proportion Hypothesis Test

Two-Proportion Inference · Tutorial 706 of 996

Setting up a Two-Proportion Hypothesis Test

Set up two-proportion hypotheses by defining the event, ordering the groups, and translating the research question into a precise difference and alternative direction.

Intermediate 8 min read

What You'll Learn

  • Define the difference between two population proportions using an explicit group order.
  • Write two-sided hypotheses for equality and for a specified difference.
  • Choose a one-sided alternative that matches the research question.
  • Translate “higher,” “lower,” and “more than a margin” into signs.
  • Distinguish hypotheses about population proportions from observed sample proportions.
  • Explain why reversing the group order reverses the direction of the difference.

Start With the Event and the Group Order

A two-proportion hypothesis test begins before any test statistic is calculated. First identify the binary event of interest, then define the two populations or groups in a fixed order. This order determines the meaning and sign of the difference, so it must be clear in the hypotheses and in the eventual interpretation.

For example, “the proportion who recovered” is not enough to specify a comparison. One must also say which group’s proportion is first. If group 1 is the treatment group and group 2 is the comparison group, the difference is treatment minus comparison. A positive value then means the event is more common in group 1; a negative value means it is more common in group 2.

Definition: Let \(p_1\) be the population proportion with a specified binary outcome in group 1, and let \(p_2\) be the population proportion with that outcome in group 2. The difference in population proportions, using the stated group order, is \(\Delta=p_1-p_2\). A positive \(\Delta\) means the outcome proportion is higher in group 1; a negative \(\Delta\) means it is higher in group 2.

The population proportions are parameters: they describe the populations or processes being studied. The sample proportions, \(\hat{p}_1\) and \(\hat{p}_2\), are calculated from observed data and can differ from sample to sample. Hypotheses for a two-proportion test are statements about \(p_1\) and \(p_2\), not about the particular sample proportions.

The usual model has a binary outcome for each individual in each group, with a common population probability \(p_1\) in group 1 and \(p_2\) in group 2. For the ordinary two-group inference framework, observations should be independent within each group and the two groups should be independent of one another. The sampling or assignment process must also support the intended population comparison. Writing hypotheses does not by itself establish that these design and independence conditions are satisfied; those are assessed when deciding whether inference is appropriate.

Equality and Two-Sided Alternatives

A question asking whether two population proportions differ in either direction is a two-sided question. “Either direction” means the outcome could be more common in group 1 or more common in group 2. Equality is expressed as a zero difference.

Definition: For a two-sided test of equality of two population proportions, write \(H_0:p_1-p_2=0\) and \(H_a:p_1-p_2\ne 0\). The null says the population proportions are equal; the alternative says they are unequal, without specifying which is larger.

This is equivalent to writing \(H_0:p_1=p_2\) and \(H_a:p_1\ne p_2\). The difference form is often more useful because it makes the group order and the tested value explicit. The alternative uses “not equal” because it includes both possible directions.

Worked Example: Asking Whether Two Proportions Differ

In a hypothetical survey, group 1 consists of 120 adults offered a new reminder system, and group 2 consists of 100 adults receiving the usual reminder. The event is “attended the scheduled appointment.” Suppose 42 people in group 1 and 30 in group 2 attended. Set up hypotheses for whether the population attendance proportions differ.

Define the parameters and order. Let \(p_1\) be the population proportion who would attend with the new reminder, and \(p_2\) the population proportion who would attend with the usual reminder. The specified difference is \(\Delta=p_1-p_2\).

Describe the observed difference only as context. The sample proportions are \(\hat{p}_1=42/120=0.350\) and \(\hat{p}_2=30/100=0.300\), so the observed sample difference is \(0.350-0.300=0.050\), or 5 percentage points. These sample values do not determine whether the test is one-sided or two-sided; that choice comes from the research question.

Write the hypotheses. Since the question asks whether the population proportions differ in either direction, use

$$ H_0:p_1-p_2=0 \qquad\text{versus}\qquad H_a:p_1-p_2\ne 0. $$

The alternative does not assert that the new reminder improves attendance. It says only that the two population attendance proportions are different.

One-Sided Alternatives Follow the Research Question

A one-sided alternative specifies which direction of difference matters. State the event and group order first, then translate the words “higher” or “lower” into a sign. If the question is whether group 1 has a larger proportion than group 2, the difference \(p_1-p_2\) should be positive under the alternative. If the question is whether group 1 has a smaller proportion, the difference should be negative.

Definition: For a one-sided test against equality, \(H_a:p_1-p_2>0\) means the population proportion is higher in group 1 than in group 2; \(H_a:p_1-p_2<0\) means it is lower in group 1. The null boundary is \(p_1-p_2=0\). In a full statement of the one-sided hypotheses, the null includes the direction opposite to the alternative: \(H_0:p_1-p_2\le 0\) versus \(H_a:p_1-p_2>0\), or \(H_0:p_1-p_2\ge 0\) versus \(H_a:p_1-p_2<0\). The test calculation uses the boundary equality value.

Many introductory presentations write the null as equality even when the alternative is one-sided, for example \(H_0:p_1-p_2=0\) versus \(H_a:p_1-p_2>0\). This is the conventional boundary formulation for the test. It identifies the null value at which the reference distribution is evaluated, while the full null hypothesis for a one-sided claim includes differences in the opposite direction as well.

Worked Example: Testing Whether an Adverse Outcome Is Less Common

Suppose a hypothetical study compares an intervention group with a usual-care group. The binary event is experiencing an adverse outcome. Among 150 people in each group, 18 in the intervention group and 27 in the usual-care group experience the event. Set up a test of whether the adverse-outcome proportion is lower in the intervention group.

Fix the order. Let \(p_1\) be the population adverse-outcome proportion for the intervention group and \(p_2\) the corresponding proportion for usual care. Thus \(\Delta=p_1-p_2\).

Check the observed direction. The sample proportions are \(\hat{p}_1=18/150=0.120\) and \(\hat{p}_2=27/150=0.180\), giving \(\hat{p}_1-\hat{p}_2=0.120-0.180=-0.060\). The observed difference is negative, or 6 percentage points lower in the intervention group. This calculation is consistent with the question, but the research question—not the observed result—sets the alternative.

Write the hypotheses. “Lower in the intervention group” means \(p_1-p_2<0\). The boundary form and the full one-sided form are

$$ H_0:p_1-p_2=0 \qquad\text{versus}\qquad H_a:p_1-p_2<0, $$

with the full null stated as \(H_0:p_1-p_2\ge 0\). A positive alternative would ask whether the adverse outcome is more common under the intervention, which is not the stated question.

Testing a Specified Difference

Not every comparison asks whether the population proportions are equal. Sometimes the question is whether their difference is a specified value, or whether it exceeds a meaningful threshold. Let \(\Delta_0\) denote the difference specified by the null question. The same structure applies: the null sets the difference to \(\Delta_0\), and the alternative states whether the true difference is different from, greater than, or less than that value.

Definition: For a specified null difference \(\Delta_0\), a two-sided test is \(H_0:p_1-p_2=\Delta_0\) versus \(H_a:p_1-p_2\ne\Delta_0\). One-sided alternatives are \(H_a:p_1-p_2>\Delta_0\) or \(H_a:p_1-p_2<\Delta_0\), with the corresponding null containing the other values and the boundary \(\Delta_0\).

The value \(\Delta_0\) is expressed on the proportion scale. For example, a difference of 0.08 is an 8-percentage-point difference, not an 8% relative increase. Keep the event, group order, and units in view when selecting \(\Delta_0\). A nonzero specified difference can represent a benchmark or a minimum improvement considered important for the question.

Worked Example: Testing Whether a Difference Exceeds a Benchmark

In a hypothetical evaluation, group 1 receives a training program and group 2 does not. The event is passing a skills assessment. A decision-maker wants to know whether the program’s pass proportion exceeds the comparison proportion by more than 8 percentage points. Suppose 64 of 200 people in group 1 and 40 of 200 in group 2 pass.

Define the difference. Let \(p_1\) be the population pass proportion with the program, let \(p_2\) be the population pass proportion without it, and define \(\Delta=p_1-p_2\). The benchmark is \(\Delta_0=0.08\).

Compute the sample difference for orientation. The sample proportions are \(\hat{p}_1=64/200=0.320\) and \(\hat{p}_2=40/200=0.200\). Their difference is \(0.320-0.200=0.120\), or 12 percentage points. The sample difference is 4 percentage points above the benchmark, since \(0.120-0.080=0.040\). This alone does not settle the population question.

Translate “exceeds by more than 8 percentage points.” The relevant claim is that \(\Delta\) is greater than \(0.08\), so the alternative is \(H_a:p_1-p_2>0.08\). The boundary form is

$$ H_0:p_1-p_2=0.08 \qquad\text{versus}\qquad H_a:p_1-p_2>0.08. $$

The full null is \(H_0:p_1-p_2\le 0.08\). It includes equality and all differences that do not exceed the benchmark. The hypotheses concern a difference in pass proportions, measured in percentage points, not a relative percentage increase.

A Short Check on Direction

The sign of a difference depends on the order of subtraction. This is a simple algebraic fact, but it explains many reversed alternatives. Define \(\Delta_{12}=p_1-p_2\). Reversing the group order gives

$$ \Delta_{21}=p_2-p_1=-(p_1-p_2)=-\Delta_{12}. $$

Therefore, if the alternative using group 1 minus group 2 is \(\Delta_{12}>0\), the equivalent alternative using group 2 minus group 1 is \(\Delta_{21}<0\). The scientific question has not changed; only the order used to define the difference has changed. This is why naming the groups in the definition is essential.

1
Name the outcome.
Specify exactly which binary event counts as a success, such as “attended” or “experienced the adverse outcome.”
2
Set the group order.
Define \(p_1\) and \(p_2\) in words, then define \(\Delta=p_1-p_2\).
3
Identify the null value.
Use zero for an equality question, or the stated benchmark \(\Delta_0\) for a specified-difference question.
4
Translate the claim into a direction.
“Different” gives \(\ne\); “greater than” gives \(>\); “less than” gives \(<\), always for the defined difference.

Common Mistakes and Why Setup Matters

A hypothesis test’s direction must be chosen before examining whether the observed difference happens to look favorable. Choosing a one-sided alternative after seeing the data changes the question in response to the result and does not provide the same inferential protection as a direction specified in advance. If the research question permits either direction, use a two-sided alternative.

  • Reversing the group order. Writing \(p_1-p_2\) but describing a positive result as “higher in group 2” reverses the interpretation. State the order and check the sign.
  • Using sample proportions in the hypotheses. Statements such as \(\hat{p}_1=\hat{p}_2\) describe observed data, not the population claim. Use \(p_1\) and \(p_2\) in \(H_0\) and \(H_a\).
  • Making the alternative match the observed result. A negative observed difference is not, by itself, a reason to choose \(H_a:p_1-p_2<0\). Choose the direction from the substantive question, preferably before examining outcomes.
  • Confusing percentage points with percent change. A difference \(p_1-p_2=0.08\) is an 8-percentage-point difference. It is not automatically an 8% relative increase.
  • Writing a one-sided null as only the opposite direction. For \(H_a:p_1-p_2>0\), the full null is \(p_1-p_2\le 0\), not merely \(p_1-p_2<0\). The equality value is the boundary used for the test calculation.

Careful setup matters because the hypotheses define the precise population claim that a test evaluates. A correctly calculated test for the wrong event, group order, or alternative direction answers the wrong question. Once the hypotheses are set, later steps can assess whether the data provide evidence against the null; the hypotheses themselves do not establish a result or imply that one group causes an outcome to change.

Check Your Understanding

For each item, define the difference using the stated group order and write the hypotheses that match the question.

  1. Group 1 is a new reminder and group 2 is the standard reminder. The event is attending an appointment. Write hypotheses for whether attendance proportions differ.
  2. Group 1 is a treatment and group 2 is control. The event is symptom resolution. Write hypotheses for whether resolution is more common in the treatment group.
  3. Group 1 is a new process and group 2 is the existing process. The event is a defective item. Write hypotheses for whether the defect proportion is lower under the new process.
  4. With \(\Delta=p_1-p_2\), write hypotheses for whether the difference is greater than 0.05.
  5. If \(\Delta=p_1-p_2\) and an alternative is \(\Delta<0\), what is the equivalent direction when the difference is instead defined as \(p_2-p_1\)?