A clinical researcher completed a trial of a blood-pressure-lowering drug with 20 patients in each group. The new drug lowered blood pressure by 6 mmHg compared with the usual drug, but the p-value came out at p = 0.14.
In the conclusion the researcher wrote: “The study proved that the new drug does not differ from the usual drug.” When the paper went to reviewers, the reply was blunt: “The study did not prove the absence of a difference. The sample was simply too small to detect a clinically important one.”
Sample size calculation is not a formality to satisfy an ethics committee. It is the scientific safeguard that stops your study from producing a false negative result because of low statistical power, or from wasting resources and exposing more patients than necessary to an experimental intervention.
Why Sample Size Is Settled Before Data Collection, Not After
When you run a study comparing two groups, you are exposed to two kinds of statistical error:
- Type I error (α): declaring a difference between the groups when there is no real difference in the population (a false positive).
- Type II error (β): failing to detect a difference that really exists in the population because your sample is small (a false negative).
Statistical power is defined as the complement of the Type II error (1 - β), that is, the probability that your statistical test succeeds in detecting the true effect if it really exists. In medical and biological studies, the methodological convention is to set the significance level α at 0.05 (two-sided) and the statistical power at no less than 80% (that is, β = 0.20), or 90% in pivotal trials.
The Four Ingredients That Determine Sample Size
To calculate the number of participants needed in each group before the study starts, you need to specify four basic inputs:
1. Significance Level (α)
The threshold at which you accept rejecting the null hypothesis. α = 0.05 is commonly adopted, which corresponds to a standard normal value of Z_(1-α/2) = 1.96 in two-sided tests.
2. Required Statistical Power (1 - β)
The target ability to detect the difference. If you choose 80% power, the corresponding standard normal value is Z_(1-β) = 0.8416 (or roughly 0.84). If you choose 90% power, Z_(1-β) = 1.2816.
3. Smallest Clinically or Practically Important Difference (Δ)
What is the smallest difference between the two means (or two proportions) that you would consider important in medical practice if it really existed? This number is not invented at random. It is drawn from clinical experience or earlier studies. The smaller the difference you look for, the larger the sample you need to see it.
4. Expected Variability or Standard Deviation (σ)
How much the outcome variable varies between individuals in the population. It is usually estimated from published studies or from a small pilot study. The more variability between individuals, the more noise there is and the larger the sample you need to isolate the effect.
(Note: the expected difference divided by the standard deviation, Δ/σ, is called Cohen’s d, the standardized effect size.)
A Worked Numerical Example With the Formula and Steps: Comparing Two Independent Means
Suppose you are planning a clinical trial comparing a new diet programme with usual care for lowering systolic blood pressure. From earlier literature and clinical experience, you have set the following inputs:
- Expected standard deviation of systolic blood pressure in this population: σ = 10 mmHg.
- Smallest clinically important difference we want to detect between the two groups: Δ = 5 mmHg (so the standardized effect size is d = 5 / 10 = 0.5).
- Two-sided significance level: α = 0.05 → Z_(1-α/2) = 1.96.
- Target statistical power: 80% → Z_(1-β) = 0.84.
- Equal allocation between the two groups (1:1).
The Standard Formula for Sample Size per Group (n)
n = (2 · σ² · (Z_(1-α/2) + Z_(1-β))²)/Δ²
The Calculation, Step by Step
- Add the two Z values:
1.96 + 0.84 = 2.80
- Square the sum:
(2.80)² = 7.84
- Compute the squared standard deviation multiplied by 2:
2 · σ² = 2 · (10)² = 2 · 100 = 200
- Multiply out the full numerator:
200 · 7.84 = 1568
- Compute the denominator (the squared difference Δ²):
Δ² = (5)² = 25
- Divide to get n per group:
n = 1568/25 = 62.72
Since there is no such thing as “part of a patient”, we always round up so that power does not fall below the required level. The number needed for analysis is therefore 63 patients per group, or 126 patients in the whole study. (Technical note: if we use the exact t-distribution correction instead of the normal approximation, as statistical software does, the figure rises by about one patient to 64 per group.)
How to Adjust Sample Size for Expected Dropout (Dropout Inflation)
The figure of 63 per group is the number of patients who must complete the study and have data in the final analysis. In practice, some participants withdraw or are lost to follow-up.
A common mistake: if you expect 20% dropout, some people multiply 63 × 1.20 = 75.6 ≈ 76 patients. If 20% of 76 patients withdraw (76 × 0.20 = 15.2 patients), you are left with only about 61 patients, which is fewer than the 63 you need!
The correct formula for dropout compensation (d_(drop)):
N_(enrolled) = n/(1 - d_(drop))
Applying it to our example with an expected dropout of 20% (d_(drop) = 0.20):
N_(enrolled) = 63/(1 - 0.20) = 63/0.80 = 78.75 → 79 patients per group
Check: if we start with 79 patients and 20% of them withdraw (79 × 0.20 = 15.8 patients), we are left with 79 - 15.8 = 63.2 patients, so full statistical power is preserved. We therefore need to recruit 79 × 2 = 158 participants at the start of the study.
Why “Post-Hoc Power” Is Not Useful
When a study’s result is not statistically significant (p > 0.05), some reviewers ask for the “observed power” (post-hoc power) calculated from the difference and standard deviation seen in the same sample.
The statistical literature shows that calculating post-hoc power from the effect size observed in the same sample is just a mathematical restatement of the p-value and adds no new information:
- If p > 0.05, the post-hoc power will come out low, usually below roughly 50% at α = 0.05.
- If p is very small, the post-hoc power will come out high.
What is the right scientific alternative after the study ends? Instead of calculating post-hoc power on the observed effect, look at the 95% confidence interval for the difference between the groups:
- If the confidence interval is narrow and lies entirely around zero, well away from the clinically important difference (for example from -2 to +2 mmHg when the clinically important difference is 5 mmHg), you have strong evidence of no clinically important effect.
- If the confidence interval is wide and includes zero and also includes the clinically important difference (for example from -1 to +8 mmHg), the study is inconclusive and needs a larger sample.
How to Write It Up in Your Research
In the statistical methods section (Sample Size Estimation), write out all the inputs clearly so that any reader or reviewer can recalculate your number and check it:
Sample reporting sentence (APA 7th edition style):
“An a priori sample size calculation was conducted for the primary outcome (systolic blood pressure). Assuming a pooled standard deviation of 10 mmHg based on prior literature, a minimum of 63 participants per group was required to detect a clinically meaningful difference of 5 mmHg (Cohen’s d = 0.50) using a two-sided independent-samples t-test at α = .05 and 80% power. Accounting for an anticipated 20% attrition rate (63 / 0.80), the recruitment target was set at 79 participants per group (N = 158 total).”
To apply this to your own data, try it on analysez.ai.