Introduction
Many clinical trials compare two groups using a binary endpoint. Examples include the proportion of patients who achieve a clinical response, the proportion experiencing an adverse event, the proportion achieving remission, or the proportion meeting a predefined treatment-success criterion.
When the outcome is binary, the primary quantity of interest is often a proportion.
For example, suppose 60% of patients receiving an experimental treatment respond compared with 40% receiving control. The investigator may want to test whether this difference is statistically significant and, before the trial begins, determine how many patients are required to have adequate probability of detecting that difference.
This is the purpose of a two-sample proportion sample-size calculation.
The Basic Two-Sample Proportion Problem
Let:
- \(p_1\) = true proportion in Group 1
- \(p_2\) = true proportion in Group 2
The parameter of interest is usually the difference:
The most common hypothesis is:
For a one-sided study, the alternative may instead be:
The sample-size calculation requires investigators to specify the proportions they expect under the planning alternative.
What Determines Sample Size?
Four major quantities drive the calculation:
- The expected proportion in Group 1.
- The expected proportion in Group 2.
- The type I error.
- The desired power.
Allocation between the groups also affects the total sample size.
| Quantity | Typical Planning Choice |
|---|---|
| Group 1 proportion | \(p_1=0.60\) |
| Group 2 proportion | \(p_2=0.40\) |
| Absolute difference | 20 percentage points |
| Two-sided type I error | 0.05 |
| Power | 0.80 or 0.90 |
| Allocation | 1:1 |
Absolute Difference Versus Relative Measures
For sample-size calculations, the most direct effect measure is the absolute difference in proportions:
For example:
The treatment difference is therefore 20 percentage points.
Other effect measures such as the relative risk and odds ratio can be useful for interpretation, but the standard two-sample proportion sample-size calculation is naturally expressed in terms of the two underlying proportions.
Why Smaller Effects Require Larger Samples
Suppose the experimental treatment is expected to have a 60% response rate and control a 40% response rate. The absolute difference is:
Now suppose the expected difference is only 5 percentage points:
The smaller effect is much harder to distinguish from random sampling variation.
The Standard Normal Approximation
For planning purposes, a commonly used large-sample formula for equal allocation is based on the normal approximation to the two-sample test for proportions.
Let:
- \(p_1\) = anticipated proportion in Group 1
- \(p_2\) = anticipated proportion in Group 2
- \(p=(p_1+p_2)/2\) = pooled planning proportion
- \(z_{1-\alpha/2}\) = two-sided type I error critical value
- \(z_{1-\beta}\) = power critical value
For equal sample sizes:
Here \(n\) is the required number of patients per group.
Where the Formula Comes From
The formula combines two sources of uncertainty.
The first term reflects the variability under the null hypothesis:
The second reflects the variability under the planning alternative:
These quantities are multiplied by the relevant normal critical values.
The resulting quantity is then divided by the squared treatment difference:
This squared difference explains why sample size rises rapidly as the target effect becomes smaller.
Critical Values for Common Designs
| Design | Typical Value |
|---|---|
| Two-sided \(\alpha=0.05\) | \(z_{1-\alpha/2}=1.96\) |
| One-sided \(\alpha=0.05\) | \(z_{1-\alpha}=1.645\) |
| 80% power | \(z_{1-\beta}=0.842\) |
| 90% power | \(z_{1-\beta}=1.282\) |
| 95% power | \(z_{1-\beta}=1.645\) |
A Complete Worked Example
Suppose a randomized clinical trial compares an experimental treatment with control using a binary response endpoint.
The investigators expect:
- 60% of patients in the experimental group to respond.
- 40% of patients in the control group to respond.
They want to detect this 20-percentage-point difference using a two-sided 5% type I error and 80% power.
| Parameter | Planning Value |
|---|---|
| Experimental proportion \(p_1\) | 0.60 |
| Control proportion \(p_2\) | 0.40 |
| Absolute difference | 0.20 |
| Two-sided \(\alpha\) | 0.05 |
| Power | 0.80 |
| Allocation | 1:1 |
Step 1: Calculate the Planning Pooled Proportion
For equal allocation, calculate:
Substituting the planning values:
Therefore:
and:
Step 2: Calculate the Alternative Variance Component
The alternative variance component is:
Substituting:
Therefore:
Step 3: Insert the Critical Values
For a two-sided 5% type I error:
For 80% power:
The formula becomes:
Step 4: Calculate the Numerator
The first component is:
The second component is:
Their sum is approximately:
Squaring gives approximately:
Multiplying by 2:
Step 5: Divide by the Squared Difference
The treatment difference is:
Therefore:
The approximate sample size per group is therefore:
Because sample size must be an integer, the normal-approximation calculation gives approximately:
The corresponding total sample size is:
Why Software May Give a Slightly Different Number
Different sample-size procedures can produce slightly different answers.
For two proportions, software may use:
- Normal approximation without continuity correction
- Normal approximation with continuity correction
- Score-test-based calculations
- Exact methods
- Unconditional exact procedures
- Alternative definitions of the planning variance
Therefore, two valid statistical programs may not return exactly the same sample size.
Equal Allocation
The simplest design allocates the same number of patients to each treatment group.
For the worked example:
This produces a total evaluable sample size of:
Equal allocation is often statistically efficient when the per-patient cost, variability, and clinical importance of the two groups are similar.
Unequal Allocation
Clinical trials do not always use a 1:1 allocation ratio.
Suppose the investigator wants twice as many patients in the experimental group as in control:
This may occur because the experimental treatment is expected to provide greater clinical benefit, because additional safety information is desired, or because recruitment considerations favor one group.
Unequal allocation generally requires more total patients than equal allocation for the same statistical power, assuming all other factors remain constant.
General Formula for Unequal Allocation
Let:
- \(n_1\) = sample size in Group 1
- \(n_2\) = sample size in Group 2
- \(r=n_1/n_2\) = allocation ratio
A commonly used normal-approximation expression can be written in terms of the allocation ratio.
One convenient representation is:
where \(n_1\) is the sample size in Group 1 and \(r=n_1/n_2\).
The sample size in Group 2 is then:
The exact expression used by software depends on the statistical test and variance convention, so unequal-allocation calculations should be verified using the intended analysis method.
Effect of Allocation Ratio
| Allocation | General Consequence |
|---|---|
| 1:1 | Usually most statistically efficient |
| 2:1 | Usually requires somewhat more total patients |
| 3:1 | Further increase in total sample size |
| 4:1 | Increasingly inefficient statistically |
The 1:1 ratio minimizes the total variance for a fixed total sample size when the two groups have comparable costs and variances.
Type I Error
The type I error is the probability of concluding that the two proportions differ when the null hypothesis is true.
For a two-sided test:
A common clinical-trial choice is:
The corresponding two-sided normal critical value is approximately:
Power
Power is the probability of detecting the specified treatment difference if that difference truly exists.
For an 80% powered study:
so:
For 90% power:
Two-Sided Versus One-Sided Testing
A two-sided test considers departures in either direction:
A one-sided test considers only one prespecified direction:
For the same nominal alpha and power, a one-sided calculation generally requires fewer patients because the critical value is smaller.
How Power Changes With Effect Size
Consider a control response rate of 40%.
Different experimental response rates correspond to different effect sizes:
| Experimental Rate | Control Rate | Difference | Difficulty |
|---|---|---|---|
| 70% | 40% | 30 percentage points | Relatively easier |
| 60% | 40% | 20 percentage points | Moderate |
| 55% | 40% | 15 percentage points | Harder |
| 50% | 40% | 10 percentage points | Much harder |
| 45% | 40% | 5 percentage points | Very difficult |
As the difference becomes smaller, the required sample size increases substantially.
Sample Size Is Sensitive to the Planning Proportions
An important practical issue is that the sample-size calculation depends on the assumed values of \(p_1\) and \(p_2\).
Suppose investigators plan for:
but the true rates are actually closer together.
The study may then have substantially less power than intended.
Clinically Meaningful Difference
A common mistake is to calculate the sample size around the largest difference that investigators hope to observe.
Instead, the calculation should generally focus on the smallest clinically important difference that the study should be able to detect.
For example, suppose a new treatment would be considered worthwhile if it increased response from 40% to at least 50%.
The study should therefore be powered around a 10-percentage-point difference, rather than assuming a larger difference simply to reduce the required sample size.
Continuity Correction
The binomial distribution is discrete, whereas the normal approximation is continuous.
A continuity correction attempts to account for this difference.
For example, a difference of integer counts may be adjusted by approximately one-half observation when approximating the discrete binomial distribution with a normal distribution.
Continuity corrections can increase the required sample size.
| Method | Typical Characteristic |
|---|---|
| Uncorrected normal approximation | Usually smaller sample size |
| Continuity-corrected approximation | Often more conservative |
| Exact method | Uses the discrete binomial distribution directly |
Dropout Inflation
The sample size calculated from the statistical formula is often the number of evaluable patients required.
Clinical trials generally enroll more patients because some participants may:
- Withdraw consent.
- Be lost to follow-up.
- Become unevaluable.
- Fail to provide the primary endpoint.
- Discontinue before the required assessment.
Suppose the required evaluable sample size is \(N\), and the anticipated dropout rate is \(d\).
The enrollment target can be inflated using:
Dropout Example
Suppose the study requires:
evaluable patients and anticipates 10% dropout.
Then:
Therefore, investigators would generally round upward to approximately:
With equal allocation, this could be implemented as:
assuming the allocation remains exactly 1:1.
Why Simple Percentage Inflation Can Be Slightly Wrong
A common shortcut is:
This produces approximately 427 patients.
However, if 10% of the enrolled population is expected to drop out, the correct inflation is:
The difference occurs because the dropout percentage applies to the enrolled population, not to the final evaluable sample.
Event Rates Near 0% or 100%
The normal approximation deserves additional caution when proportions are close to zero or one.
For example:
or:
can produce conditions in which the standard normal approximation is less reliable.
In these situations, investigators should consider methods based directly on the binomial distribution or other appropriate procedures.
Rare Events
If the binary endpoint is rare, the number of observed events can be small even when the total sample size is substantial.
For example, an adverse-event rate of 2% versus 1% represents only a one-percentage-point difference.
The study may require a very large number of patients to reliably distinguish these rates.
Risk Difference, Risk Ratio, and Odds Ratio
Although sample size is often planned using two proportions, the eventual analysis may report several effect measures.
Risk Difference
Risk Ratio
Odds Ratio
For example, with:
the risk difference is:
the risk ratio is:
and the odds ratio is:
These are different descriptions of the same assumed pair of proportions.
Sample Size for a Non-Inferiority Study
Two-sample proportion calculations can also arise in non-inferiority trials.
The hypothesis structure changes because the goal is not necessarily to demonstrate superiority.
For example, if higher response is better and \(\delta\) is the acceptable non-inferiority margin, a simplified hypothesis might involve:
Non-inferiority sample-size calculations require careful attention to the direction of the endpoint, the margin, one-sided type I error, and the exact analysis method.
Power Versus Sample Size
Increasing the sample size generally increases power.
For example, suppose all other assumptions remain fixed.
| Power Target | Relative Sample Size |
|---|---|
| 80% | Baseline planning requirement |
| 85% | Higher |
| 90% | Higher still |
| 95% | Substantially higher |
The relationship is not linear.
Moving from 80% to 90% power can require a meaningful increase in sample size, particularly when the target effect is modest.
Why 90% Power Is Common in Some Clinical Trials
An 80% power target corresponds to a 20% probability of failing to detect the specified effect under the planning alternative.
A 90% power target reduces this probability to 10%.
versus:
The appropriate target depends on the importance of the endpoint, regulatory expectations, consequences of a false-negative conclusion, feasibility, and other design considerations.
Sample Size and Multiplicity
If the trial has multiple primary hypotheses or multiple co-primary endpoints, the effective type I error allocation may differ from a simple 0.05 test.
For example, if a design allocates alpha across multiple hypotheses, the critical value entering the sample-size calculation may be different.
Clustered or Correlated Binary Outcomes
The standard two-sample proportion formula assumes independent observations.
That assumption may not hold in cluster-randomized trials, repeated binary measurements, or other correlated designs.
Correlation reduces the effective information contributed by each observation.
In a cluster-randomized study, a design effect may be applied, often involving the intracluster correlation coefficient (ICC) and cluster size.
where:
- \(m\) = average cluster size
- \(\rho\) = intracluster correlation coefficient
The resulting sample size can be substantially larger than the independent two-sample calculation.
Stratification and Covariate Adjustment
Randomized trials often use stratification or covariate-adjusted analyses.
The simple two-proportion calculation provides a useful baseline, but the actual analysis may be based on:
- Cochran–Mantel–Haenszel methods
- Logistic regression
- Stratified risk differences
- Adjusted risk ratios
- Other prespecified covariate-adjusted models
If the primary analysis differs materially from the simple unadjusted two-proportion comparison, the sample-size method should be evaluated to ensure that it provides adequate power for the intended analysis.
R Implementation
R provides several ways to perform two-sample proportion sample-size calculations.
A standard starting point is the built-in
power.prop.test() function.
power.prop.test( p1 = 0.60, p2 = 0.40, power = 0.80, sig.level = 0.05, alternative = "two.sided" )
This function returns the required approximate sample size per group under its specified method.
Solving for Sample Size Directly
The same function can be used without specifying the sample size.
result <- power.prop.test( p1 = 0.60, p2 = 0.40, power = 0.80, sig.level = 0.05, alternative = "two.sided" ) result
The output includes the calculated sample size along with the other planning parameters.
Checking the Result
A good practice is to verify the result using a second calculation.
p1 <- 0.60
p2 <- 0.40
alpha <- 0.05
power_target <- 0.80
z_alpha <- qnorm(1 - alpha / 2)
z_beta <- qnorm(power_target)
p_bar <- (p1 + p2) / 2
n <-
2 *
(
z_alpha * sqrt(2 * p_bar * (1 - p_bar)) +
z_beta * sqrt(
p1 * (1 - p1) +
p2 * (1 - p2)
)
)^2 /
(p1 - p2)^2
ceiling(n)
This reproduces the approximate normal-theory calculation described earlier.
Creating a Reusable R Function
For repeated sample-size calculations, it is useful to create a function.
two_prop_n <- function(
p1,
p2,
alpha = 0.05,
power = 0.80
) {
z_alpha <- qnorm(1 - alpha / 2)
z_beta <- qnorm(power)
p_bar <- (p1 + p2) / 2
n <-
2 *
(
z_alpha * sqrt(2 * p_bar * (1 - p_bar)) +
z_beta * sqrt(
p1 * (1 - p1) +
p2 * (1 - p2)
)
)^2 /
(p1 - p2)^2
ceiling(n)
}
two_prop_n(
p1 = 0.60,
p2 = 0.40,
alpha = 0.05,
power = 0.80
)
Exploring Different Effect Sizes in R
One of the most useful applications is to see how sample size changes as the target effect changes.
control <- 0.40
experimental_rates <-
c(0.45, 0.50, 0.55, 0.60, 0.65, 0.70)
sample_sizes <- sapply(
experimental_rates,
function(p1) {
two_prop_n(
p1 = p1,
p2 = control,
alpha = 0.05,
power = 0.80
)
}
)
data.frame(
experimental_rate = experimental_rates,
control_rate = control,
difference = experimental_rates - control,
n_per_group = sample_sizes,
total_n = 2 * sample_sizes
)
This table demonstrates an important planning concept: small changes in the target effect size can produce large changes in the required sample size.
Exploring Power in R
After selecting a sample size, investigators can calculate the resulting power for different true treatment effects.
p1_values <- c(
0.45,
0.50,
0.55,
0.60,
0.65,
0.70
)
power_values <- sapply(
p1_values,
function(p1) {
power.prop.test(
p1 = p1,
p2 = 0.40,
n = 194,
sig.level = 0.05,
alternative = "two.sided"
)$power
}
)
data.frame(
p1 = p1_values,
p2 = 0.40,
power = power_values
)
This is useful because the study's actual power is not a single universal number. It depends on the true underlying proportions.
Power as a Function of the True Difference
Define:
The resulting power surface depends on both proportions.
For a fixed control proportion, power generally increases as the experimental proportion moves farther away from the control value.
Sample Size Sensitivity Analysis
A strong statistical analysis plan should not rely on only one arbitrary planning scenario.
Investigators can evaluate a range of assumptions.
| Scenario | \(p_1\) | \(p_2\) | Difference | Planning Question |
|---|---|---|---|---|
| Optimistic | 0.65 | 0.40 | 25% | What if treatment effect is large? |
| Primary | 0.60 | 0.40 | 20% | Main design assumption |
| Conservative | 0.55 | 0.40 | 15% | What if effect is smaller? |
| Very conservative | 0.50 | 0.40 | 10% | What if effect is modest? |
Such sensitivity analyses help the study team understand how robust the enrollment requirement is to uncertainty in the assumptions.
Choosing the Planning Proportions
Sources of information can include:
- Previous randomized clinical trials
- Historical control data
- Phase I or Phase II studies
- Published literature
- Real-world data
- Pilot studies
- Clinical expert judgment
- Regulatory or development-program objectives
Historical data should be interpreted carefully because response rates can change across populations, endpoint definitions, treatment lines, follow-up periods, and assessment criteria.
The Control Rate Is Especially Important
Suppose the experimental treatment is expected to have a 60% response rate.
If the control rate is assumed to be 30%, the expected difference is:
But if the control rate is expected to be 50%, the difference is only:
These scenarios can require dramatically different sample sizes.
Unequal Group Costs
Statistical efficiency is not the only consideration when choosing an allocation ratio.
Suppose one treatment is substantially more expensive than another. An investigator may prefer unequal allocation even though it requires more total patients.
The design therefore involves a tradeoff between:
- Statistical efficiency
- Treatment exposure
- Cost
- Safety information
- Recruitment feasibility
- Ethical considerations
Ethical Considerations
Sample-size planning is also an ethical issue.
An underpowered study can expose participants to an experimental intervention without a reasonable probability of answering the scientific question.
An unnecessarily oversized study can expose more participants than necessary.
Interim Analyses and Sample Size Re-Estimation
Some trials allow sample-size re-estimation during the study.
For example, investigators may update an estimate of the nuisance parameter or reassess assumptions about event rates.
However, unplanned changes based on observed treatment differences can affect type I error and should not be treated as a simple administrative adjustment.
If adaptive sample-size re-estimation is planned, its statistical properties should be established in advance.
Missing Data
The standard formula assumes that the analyzed observations contribute valid binary outcomes.
Missing primary endpoint data can reduce the effective sample size.
The protocol and statistical analysis plan should therefore define:
- What constitutes an evaluable patient
- How missing responses are handled
- Whether replacement is permitted
- How intercurrent events affect the endpoint
- Which analysis population is primary
The dropout inflation should be consistent with the assumptions used in the analysis.
Intention-to-Treat Versus Per-Protocol
In randomized trials, binary endpoints may be analyzed using different populations.
An intention-to-treat analysis generally includes patients according to their randomized treatment assignment.
A per-protocol analysis may exclude certain protocol deviations.
If the primary analysis is based on intention-to-treat, the sample-size calculation should be interpreted in terms of the expected endpoint availability in that population.
Common Mistakes
- Using the wrong effect size. Sample size should be based on the smallest clinically meaningful difference, not simply the largest anticipated difference.
- Confusing total sample size with sample size per group. Always verify what the formula or software reports.
- Forgetting dropout inflation. The statistical calculation often describes evaluable patients rather than patients who must be randomized.
- Using a two-sided formula for a one-sided design or vice versa. The critical value must match the planned hypothesis test.
- Choosing a one-sided test merely to obtain a smaller sample size. The testing direction must be scientifically justified.
- Ignoring unequal allocation. The allocation ratio affects statistical efficiency.
- Assuming the normal approximation is always appropriate. Rare events and proportions near 0 or 1 may require more careful methods.
- Ignoring multiplicity. Multiple primary hypotheses may require an adjusted alpha allocation.
- Using unrealistic response-rate assumptions. Poor assumptions can result in a study that is underpowered or unnecessarily large.
- Reporting only the final sample size. The statistical method, assumptions, alpha, power, allocation, and dropout assumptions should also be documented.
A Practical Two-Sample Proportion Workflow
What Should Be Reported in the Protocol?
A reproducible sample-size section should specify at least:
- Primary endpoint
- Statistical hypothesis
- Expected proportion in each group
- Clinically meaningful difference
- Type I error
- One-sided or two-sided testing
- Target power
- Allocation ratio
- Sample-size calculation method
- Continuity correction, if applicable
- Required evaluable sample size
- Expected dropout rate
- Total enrollment target
- Any adjustment for multiplicity
- Any inflation for clustering or other design effects
Worked Example Summary
The main example can be summarized as follows.
| Component | Value |
|---|---|
| Endpoint | Binary response |
| Experimental response rate | 60% |
| Control response rate | 40% |
| Absolute difference | 20 percentage points |
| Two-sided type I error | 5% |
| Target power | 80% |
| Allocation | 1:1 |
| Approximate evaluable N per group | 194 |
| Approximate evaluable total N | 388 |
| Dropout assumption | 10% |
| Approximate enrollment total after inflation | 432 |
| Approximate enrollment per group | 216 |
The Most Important Concept
The most important idea in two-sample proportion sample-size planning is that sample size is driven by the signal you need to distinguish from random variation.
The signal is the difference:
The statistical noise depends on the proportions themselves, the allocation ratio, and the sample size.
The study must be large enough that the anticipated clinically meaningful difference can be detected with the desired probability while maintaining the specified type I error.
In practical terms:
- Larger treatment differences require fewer patients.
- Smaller treatment differences require more patients.
- Higher power requires more patients.
- Smaller alpha requires more patients.
- Unequal allocation generally requires more total patients.
- Dropout increases the enrollment target.
- Rare events require particular care with asymptotic methods.
References
Fleiss, J.L., Tytun, A. & Ury, H.K. (1980).
A simple approximation for calculating sample sizes for comparing
independent proportions.
Biometrics, 36(2), 343–346.
Fleiss, J.L., Levin, B. & Paik, M.C. (2003).
Statistical Methods for Rates and Proportions.
3rd ed. Wiley.
Chow, S.-C., Shao, J., Wang, H. & Lokhnygina, Y. (2017).
Sample Size Calculations in Clinical Research.
3rd ed. CRC Press.
Julious, S.A. (2009).
Sample Sizes for Clinical Trials.
Chapman & Hall/CRC.
Agresti, A. (2013).
Categorical Data Analysis.
3rd ed. Wiley.
Newcombe, R.G. (1998).
Interval estimation for the difference between independent
proportions: comparison of eleven methods.
Statistics in Medicine, 17, 873–890.