Sample Size Calculator
How many participants does your study need? 16 designs — prevalence and mean estimation, two means or proportions, paired data, ANOVA, correlation, regression, chi-square, survival, non-inferiority — with the worked formula, power curve, losses, design effect and matching R/Python code
Why use it
An underpowered study cannot answer its question and exposes participants to research without benefit; an oversized one wastes resources and time. Ethics committees, funders and journals (CONSORT item 7a, SPIRIT item 14, STROBE item 10) require the sample size to be justified, with every assumption stated. Beginners usually stumble on the inputs, not on the arithmetic: what effect to expect, where the standard deviation comes from, what one-sided means. Each input here carries a plain-language explanation of what it is and where to obtain it.
About
The Sample Size Calculator answers the first statistical question of any study: how many participants are needed. It covers the designs most used in clinical and biomedical research — estimating a mean or a prevalence with a chosen precision; comparing one mean or one proportion with a reference value; comparing two independent or paired means; two independent or paired proportions (McNemar); three or more means (one-way ANOVA); correlation; multiple linear regression; chi-square tests; logistic regression by events per variable; survival with the log-rank test or Cox model; and non-inferiority or equivalence for means and proportions. For each design the calculator shows the textbook formula with your numbers substituted step by step, so the result can be checked by hand and copied into a protocol. Where an exact method exists — the non-central t, F and chi-square distributions used by R `pwr` and G*Power — the headline result uses it, and the normal-approximation formula is shown alongside. It then applies a design effect for cluster sampling and the adjustment for expected losses (dividing by one minus the loss rate), draws the power curve, computes the power achieved with any fixed sample, and gives R and Python code that reproduces the same number.
When to use
- Writing a research protocol, grant application or ethics submission
- Planning a prevalence survey or the estimation of a mean with a given margin of error
- Designing a randomized trial, a case–control or cohort comparison, or a before–after study
- Planning correlation and regression analyses, or a logistic or survival model
- Designing a non-inferiority or equivalence trial
- Checking what power a fixed, already available sample gives (before data are analysed — not after)
Method
Pearls & pitfalls
- The effect size is a clinical decision, not a statistical one: use the minimal clinically important difference, not the difference you hope to find.
- Cohen’s small/medium/large conventions are a last resort when nothing else is known; effects from small pilot studies tend to be overestimated.
- Losses are handled by dividing: 120 / (1 − 0.20) = 150, not 120 × 1.20 = 144. Apply it last, after any finite-population correction or design effect.
- In survival studies power depends on the number of events, not on the number of participants.
- Unequal groups always need more participants in total than equal groups for the same power.
- “Observed power” computed after the study from the observed effect adds nothing to the p-value; report confidence intervals instead.
- When a rule of thumb (e.g. 10 events per variable, Green’s 50 + 8m) and a power calculation both apply, use the larger number.
Next steps
State in the protocol every value used (α, power, sidedness, effect size and its source, SD or proportions, allocation ratio, expected losses, design effect) and the software or formula. Then choose the analysis with the Statistical Test Chooser: the sample size must be calculated for the test that will actually be used.
Evidence
Formulas follow standard references (Cohen 1988; Fleiss, Levin & Paik 2003; Chow, Shao & Wang 2008; Connor 1987; Schoenfeld 1983; Freedman 1982; Peduzzi et al. 1996; Green 1991) and chapter 6 of the course manual Applied Biostatistics (G. de Macedo Oliveira). The exact methods (one-sample, two-sample and paired t tests; one-way ANOVA; multiple regression; chi-square) reproduce R package pwr (Champely) to six significant figures, and the worked examples of the manual (correlation, multiple regression, events per variable and the loss adjustment) are part of the automatic test suite. The R and Python snippets shown for each design were executed and print the same number as the calculator.
References
- Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum; 1988. — link
- Fleiss JL, Levin B, Paik MC. Statistical Methods for Rates and Proportions. 3rd ed. Hoboken, NJ: Wiley; 2003. — link
- Chow SC, Shao J, Wang H, Lokhnygina Y. Sample Size Calculations in Clinical Research. 3rd ed. Boca Raton: CRC Press; 2017. — link
- Connor RJ. Sample size for testing differences in proportions for the paired-sample design. Biometrics. 1987;43(1):207–211. — link
- Schoenfeld DA. Sample-size formula for the proportional-hazards regression model. Biometrics. 1983;39(2):499–503. — link
- Freedman LS. Tables of the number of patients required in clinical trials using the logrank test. Stat Med. 1982;1(2):121–129. — link
- Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR. A simulation study of the number of events per variable in logistic regression analysis. J Clin Epidemiol. 1996;49(12):1373–1379. — link
- Riley RD, Ensor J, Snell KIE, et al. Calculating the sample size required for developing a clinical prediction model. BMJ. 2020;368:m441. — link
- Green SB. How many subjects does it take to do a regression analysis? Multivariate Behav Res. 1991;26(3):499–510. — link
- Faul F, Erdfelder E, Lang AG, Buchner A. G*Power 3: a flexible statistical power analysis program. Behav Res Methods. 2007;39(2):175–191. — link
- Champely S. pwr: Basic Functions for Power Analysis. R package (CRAN). — link
- Moher D, Hopewell S, Schulz KF, et al. CONSORT 2010 explanation and elaboration (item 7a, sample size). BMJ. 2010;340:c869. — link