Sample size for comparing two means
Size two independent groups to detect a meaningful mean difference, using a common standard deviation and exact noncentral t power.
Fit
When to use it, and when not to
Use it when
- You will compare a continuous outcome between two independent groups.
- A common population standard deviation is a defensible planning assumption.
Not when
- The same people provide both measurements. Size a paired mean change. Read: Sample size for a paired mean change
- The groups have substantially different spreads. Plan an unequal-variance calculation for the intended Welch test. Read: Two-sample t-test
- Patients share clinics or wards. Plan power for that clustered design. Read: Simulation-based power and sample-size planning
Before you start
What you need
- The meaningful difference and common standard deviationSupply delta, the absolute difference to detect, and sd, the common population SD. Both must be positive.
- The allocation ratioSupply ratio as group 2 divided by group 1. The default is equal allocation; the engine imposes a minimum of 0.05.
- The two-sided significance levelAlpha is the chance of rejecting a true null under the model. Supply a probability between zero and one.
- The target powerPower is the chance of rejecting the null at the assumed effect. The engine limits this input to 0.5 through 0.999.
- The units counted in the sample size are independent.How to check: Check for shared clinics, families or repeated observations before using an individual-level calculation.
- The effect and spread are defensible planning values.How to check: Use prior data and clinical judgment. Repeat the calculation with smaller effects and larger spreads.
- The t model uses normal outcomes with the same population variance in both groups.How to check: Check expected spread and extreme values. A Welch analysis needs its own unequal-variance sizing assessment.
Plain language
How it works
The engine compares a meaningful difference with its standard error under a common population SD. It uses both tails of the noncentral t distribution.
For group counts n1 and n2, the standard error is SD times the square root of (1/n1 + 1/n2). Degrees of freedom are n1 + n2 minus two.
It searches integer counts, rounding group 2 up from the allocation ratio. Power at a supplied total splits that total by the ratio without integer rounding.
The linked two-sample article teaches Welch. Its unequal-variance test differs from this sizing model. Choosing a sample-size method helps check whether this model fits.
Worked example
A worked example
- Setting
- Two independent trial groups will provide a blood pressure outcome.
- Question
- How many people with observed outcomes are needed in each group?
- Approach
- Use delta = 5; sd = 10; ratio = 1; alpha = 0.05; power = 0.8. Differences and SD are in mmHg.
- Result
- The engine returns 64 in group 1 and 64 in group 2: 128 people total. Power at that total is 80.15%.
- What it means
- These are analyzable counts under a common-SD model. Recruitment losses need a separate allowance. The calculation does not establish clinical importance.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
This calculation assumes a common population SD. It does not size an unequal-variance Welch test exactly, despite linking to the two-sample t-test article. Clustering and incomplete outcomes need separate planning.
- Using a standard error as the standard deviation.Instead: Supply the spread of individual outcomes in the outcome units.
- Treating the sizing calculation as exact power for Welch.Instead: The engine pools the assumed variance. Assess unequal variances with a method matched to the planned analysis.
Inside Mallard
How Mallard uses this
For two means, Mallard returns both group counts, their total and power at a supplied total, conditional on the allocation ratio and common SD.
analysis.sample_size_two_means, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- Sample sizes for clinical trials with normal data. (opens in a new tab) · Stat Med · doi 10.1002/sim.1783
- Statistics review 4: sample size calculations. (opens in a new tab) · Crit Care · doi 10.1186/cc1521