Tutorials › Introduction to Statistics › Planning Sample Size for a Proportion Test

Errors, Power and Sample Size · Tutorial 684 of 996

Planning Sample Size for a Proportion Test

Use the normal approximation to calculate and assess a sample size for detecting a prespecified change in one population proportion.

Intermediate 10 min read

What You'll Learn

  • Identify the null proportion and the alternative proportion used in planning.
  • Distinguish the standard error under the null from the standard deviation under the alternative.
  • Calculate a sample size for a one-sided proportion test at a target significance level and power.
  • Use an approximate formula for planning a two-sided test.
  • Round sample sizes up and check whether normal approximations are reasonable.
  • Recognize why a planned sample size depends on the effect the study aims to detect.

Why Plan Sample Size for a Proportion Test?

A study measuring a proportion might ask whether a new reminder changes the fraction of patients who attend appointments, or whether a product defect rate has fallen below a specified level. Before collecting data, researchers need to decide how many independent observations to gather. Too small a sample may often miss a practically important difference; a planned sample size connects the study’s resources to its intended ability to detect that difference.

For this calculation, specify the proportion under the null hypothesis, a particular alternative proportion worth detecting, the significance level \(\alpha\), and the desired power \(1-\beta\). The resulting sample size is a planning approximation, not a promise that a future study will achieve exactly its target power.

Definition: In a one-proportion test, \(p_0\) is the population proportion specified by the null hypothesis, and \(p_1\) is a particular proportion under the alternative used for planning. The target power \(1-\beta\) is the probability that the test rejects \(H_0\) when the true proportion is \(p_1\). A planned sample size is the number of independent observations needed to attain approximately that power at the chosen significance level \(\alpha\), under the stated model and approximation.

The One-Proportion Z-Test Model

Suppose \(n\) independent observations each have a binary outcome, such as “attended” or “did not attend.” Let \(X\) be the number with the outcome of interest, and let \(\hat{p}=X/n\) be the observed sample proportion. Under a population proportion \(p\), \(X\) has a binomial distribution with parameters \(n\) and \(p\). When the normal approximation is reasonable, \(\hat{p}\) is approximately normal with mean \(p\) and standard deviation \(\sqrt{p(1-p)/n}\).

For a test of \(H_0:p=p_0\), the one-proportion z statistic uses the null standard error. Under the normal approximation, it is compared with standard normal critical values. For a one-sided test, the critical value is \(z_{1-\alpha}\); for a two-sided test, the critical values are \(-z_{1-\alpha/2}\) and \(z_{1-\alpha/2}\). Here \(z_q\) is the \(q\) quantile of the standard normal distribution.

Model and conditions: The observations must be independent Bernoulli outcomes with a common population proportion, and the sample size must be fixed by the design. The normal approximation should be checked under both \(p_0\) and the planning value \(p_1\): the expected counts \(np\) and \(n(1-p)\) should be sufficiently large at each value. A common guideline is that each expected count is at least 10. If this check fails, the normal-based calculation may be unreliable and a more suitable method is needed.

The test statistic’s standard error under \(H_0\) is \(\sqrt{p_0(1-p_0)/n}\). But when calculating power at \(p_1\), the sampling distribution of \(\hat{p}\) has standard deviation \(\sqrt{p_1(1-p_1)/n}\). The two quantities serve different purposes: the first sets the test’s rejection boundary, and the second describes how sample proportions vary at the alternative.

Deriving a One-Sided Sample-Size Formula

First consider an upper-tailed test, \(H_0:p=p_0\) against \(H_a:p>p_0\), with a planned alternative \(p_1>p_0\). The normal-approximation rejection boundary for \(\hat{p}\) is \(p_0+z_{1-\alpha}\sqrt{p_0(1-p_0)/n}\). To attain power \(1-\beta\), require this boundary to lie approximately \(z_{1-\beta}\) alternative standard deviations below the mean \(p_1\). Thus:

$$ p_0+z_{1-\alpha}\sqrt{\frac{p_0(1-p_0)}{n}} = p_1-z_{1-\beta}\sqrt{\frac{p_1(1-p_1)}{n}}. $$

Move \(p_0\) to the right and collect the terms containing \(1/\sqrt{n}\). Squaring both sides then gives the planning formula. For a lower-tailed test, the same expression applies using the absolute difference between the planned proportions and the corresponding one-sided critical quantile.

$$ n \approx \frac{ \left[ z_{1-\alpha}\sqrt{p_0(1-p_0)} + z_{1-\beta}\sqrt{p_1(1-p_1)} \right]^2 }{ (p_1-p_0)^2 }. $$

This formula treats the target power as the probability of crossing the rejection boundary in the planned direction. For a one-sided test, it follows directly from the normal approximation. The calculated value is generally not an integer, so round it up to ensure the planned sample is at least as large as the calculation.

Worked Example: Detecting an Increase in Attendance

A clinic wants to test \(H_0:p=0.20\) against \(H_a:p>0.20\), where \(p\) is the proportion of invited patients who attend. It regards an increase to \(p_1=0.30\) as important to detect. Find the approximate sample size for \(\alpha=0.05\) and target power \(0.80\).

The relevant quantiles are \(z_{0.95}=1.645\) and \(z_{0.80}=0.842\). Substitute \(p_0=0.20\), \(p_1=0.30\), and \(p_1-p_0=0.10\):

$$ n \approx \frac{ \left[1.645\sqrt{0.20(0.80)}+0.842\sqrt{0.30(0.70)}\right]^2 }{(0.30-0.20)^2} = \frac{(1.645(0.400)+0.842(0.4583))^2}{0.0100} \approx 109.0. $$

Round up to plan for 109 patients. At this sample size, the expected counts under \(p_0=0.20\) are \(109(0.20)=21.8\) attenders and \(87.2\) non-attenders. Under \(p_1=0.30\), they are \(32.7\) and \(76.3\). All exceed 10, so the usual expected-count guideline is met at both planning proportions. Under the stated normal approximation, this design targets 80% power to detect an attendance proportion of 0.30 with an upper-tailed test at the 5% significance level.

Planning a Two-Sided Test

If departures in either direction matter, use \(H_a:p\ne p_0\). The test allocates \(\alpha/2\) to each tail, so its critical values are \(\pm z_{1-\alpha/2}\). A convenient planning formula replaces \(z_{1-\alpha}\) in the one-sided formula with \(z_{1-\alpha/2}\). For a specified alternative \(p_1\), it is a common approximation that treats power in the direction of \(p_1-p_0\) as the relevant tail and neglects the very small probability of rejection in the opposite tail.

$$ n \approx \frac{ \left[ z_{1-\alpha/2}\sqrt{p_0(1-p_0)} + z_{1-\beta}\sqrt{p_1(1-p_1)} \right]^2 }{ (p_1-p_0)^2 }. $$

The two-sided normal approximation also makes it possible to check the power more directly. Its rejection region for \(\hat{p}\) is below or above \(p_0\) by \(z_{1-\alpha/2}\sqrt{p_0(1-p_0)/n}\). Under the planned alternative, approximate power is the sum of the probabilities that a normal variable with mean \(p_1\) and standard deviation \(\sqrt{p_1(1-p_1)/n}\) falls below the lower boundary or above the upper boundary. This check includes both tails and can confirm whether the simplified planning formula is adequate.

Worked Example: A Two-Sided Test of a Response Proportion

A service currently receives a response from 50% of customers. A planned study will test \(H_0:p=0.50\) against \(H_a:p\ne0.50\), with \(\alpha=0.05\), and aims for 90% power if the true response proportion is \(p_1=0.60\). Using the two-sided planning formula, \(z_{0.975}=1.960\) and \(z_{0.90}=1.282\):

$$ n \approx \frac{ \left[1.960\sqrt{0.50(0.50)}+1.282\sqrt{0.60(0.40)}\right]^2 }{(0.60-0.50)^2} = \frac{(1.960(0.500)+1.282(0.4899))^2}{0.0100} \approx 258.6. $$

Rounding up gives a planned sample size of 259 customers. The null expected counts are \(129.5\) in each outcome category; under the planned alternative they are \(155.4\) responses and \(103.6\) non-responses. The count guideline is satisfied under both proportions.

For a two-tail check, the null-based boundaries are approximately \(0.500\pm1.960\sqrt{0.25/259}\), or \(0.4391\) and \(0.5609\). Under \(p_1=0.60\), the standard deviation is \(\sqrt{0.24/259}\approx0.03044\). The upper-tail probability is approximately \(P(Z>(0.5609-0.6000)/0.03044)=P(Z>-1.285)\), or 0.9005. The lower-tail probability is approximately \(P(Z<(0.4391-0.6000)/0.03044)=P(Z<-5.285)\), which is negligible. The two-tail normal approximation therefore gives power of about 0.9005, consistent with the 90% target.

Checking the Approximation and Choosing Inputs

A sample-size formula is only as useful as its inputs and assumptions. The null proportion \(p_0\) comes from the hypothesis being tested. The alternative proportion \(p_1\) should represent a specific difference that would matter for the study, not an effect selected merely because it gives a convenient sample size. The direction of the test must also match the research question and be chosen before observing the data.

After calculating \(n\), check expected counts using both planning proportions: evaluate \(np_0\), \(n(1-p_0)\), \(np_1\), and \(n(1-p_1)\). Meeting the common threshold of 10 supports the normal approximation but does not make the binomial distribution exactly normal. If the proportions are very close to 0 or 1, or the expected counts are small, the approximation may not be dependable even when the arithmetic in the formula is correct. A normal-based sample size should then be treated cautiously.

The following sequence keeps the planning calculation tied to the intended test:

1
Specify the test.
Write \(H_0:p=p_0\) and the planned alternative direction. Decide whether the test is one-sided or two-sided on substantive grounds.
2
Set the targets.
Choose the significance level \(\alpha\), the desired power \(1-\beta\), and a meaningful planning value \(p_1\).
3
Calculate and round up.
Use the matching normal-approximation formula and round the result up to a whole observation.
4
Check the conditions.
Assess independence, the common-proportion model, and the expected counts under both \(p_0\) and \(p_1\).

Worked Example: Planning for a Decrease

A program is designed to reduce a binary event rate from \(p_0=0.08\). Researchers want a lower-tailed test against \(p_1=0.04\), with \(\alpha=0.01\) and target power \(0.90\). Since \(z_{0.99}=2.326\) and \(z_{0.90}=1.282\), the one-sided calculation is:

$$ n \approx \frac{ \left[2.326\sqrt{0.08(0.92)}+1.282\sqrt{0.04(0.96)}\right]^2 }{(0.04-0.08)^2} = \frac{(2.326(0.2713)+1.282(0.1960))^2}{0.0016} \approx 486.5. $$

The planned sample size is therefore 487 observations. At \(p_0\), the expected event and non-event counts are \(38.96\) and \(448.04\); at \(p_1\), they are \(19.48\) and \(467.52\). These satisfy the common expected-count guideline. The plan targets 90% power to detect a reduction from 8% to 4%, using a lower-tailed test at the 1% significance level.

Common Mistake and Key Takeaway

A frequent error is to use the null standard deviation for both parts of the calculation. For example, substituting \(\sqrt{p_0(1-p_0)}\) in place of \(\sqrt{p_1(1-p_1)}\) in the power term assumes that sample proportions vary under the alternative as they do under the null. They generally do not: under \(p_1\), the variance of \(\hat{p}\) is \(p_1(1-p_1)/n\). Use the null proportion to locate the test’s rejection boundary and the alternative proportion to describe the distribution when calculating power.

Sample-size planning for a proportion test therefore depends on a complete set of choices: the null value, a meaningful alternative, the test direction, \(\alpha\), and target power. The result is an approximate design calculation whose conditions and expected counts must be checked, not a sample size that guarantees a particular outcome.

Check Your Understanding

Answer each question using the definitions and methods in this tutorial.

  1. For an upper-tailed one-proportion test, what does \(p_1\) represent, and why is it needed in a sample-size calculation?
  2. In the one-sided formula, which proportion determines the test’s rejection boundary, and which determines the sampling standard deviation under the alternative?
  3. A two-sided test uses \(\alpha=0.05\). Which standard normal quantile determines its critical value?
  4. Why should a calculated sample size be rounded up rather than to the nearest integer?
  5. For a proposed sample size, which four expected counts should be checked to assess the normal approximation at the null and planned alternative?