Sample size & power calculator
Calculate the sample size or the power for the most common study designs. Every calculation runs in R, and the exact R code is shown with the result, so you can reproduce it and report it in your protocol.
- Calculated in R
- Reproducible R code
- Methods-section wording
- Free
Designs included
- Two proportions and two means: two independent groups, equal or unequal sizes
- Paired means: before-and-after or matched pairs
- One mean or one proportion: one group against a target value
What the inputs mean
- Difference: the smallest effect that matters clinically
- Standard deviation: the spread of the outcome
- Significance level: risk of a false positive, usually 0.05
- Power: chance of detecting a real effect, usually 80–90%
How it is calculated
- Means: t distribution (noncentral t for unequal groups)
- Proportions: normal approximation, no continuity correction
- Results rounded up, then divided by (1 − dropout)
- Base R only: no packages needed
Frequently asked questions
What do I need before calculating a sample size?
You need the study design, the main outcome, the smallest difference worth detecting, the variability of the outcome (a standard deviation for continuous outcomes, or the expected percentage in the comparison group), the significance level (usually 0.05) and the power (usually 80% or 90%).
Which design should I choose?
Choose two proportions or two means when you compare two independent groups, paired means when the same participants are measured twice or are matched in pairs, and one mean or one proportion when you compare a single group with a known or target value.
How is the calculation done?
The calculation runs in R. Means use the t distribution, with the noncentral t for unequal groups and base R power.t.test for paired and one-sample designs; proportions use the normal approximation without continuity correction. The exact R code is shown under the result so you can reproduce it.
Why add participants for dropout?
Participants who withdraw or have missing outcomes reduce the number analysed. Dividing the calculated sample size by one minus the expected dropout rate keeps the analysed number close to the target.
Can I use the result in my protocol or ethics application?
Yes. Copy the suggested sentence for the methods section and the R code, and report the assumptions behind your inputs, such as the source of the expected difference and standard deviation. For complex designs, StatisMed can prepare a full sample size justification.

