LabCanvas
Free account · save your work, full figure editorSign up free

Sample size calculator (power analysis)

For a two-sample t test with a medium effect (Cohen’s d = 0.5), α = 0.05 two-sided and 80% power you need 64 participants per group, 128 in total. Choose the test (two-sample t, paired t, two proportions, one-way ANOVA or correlation), enter the expected effect as an effect size or as means and SDs, proportions or group means, and set α, power, one- or two-sided and the allocation ratio. The calculator gives the smallest sample size that reaches the target power, or the power of a sample size you already have, with a power curve. t tests use the exact noncentral t distribution, the same calculation as G*Power and R’s pwr.t.test.

What it does
Finds the sample size for a target power (or the power for a given n) for t tests, two proportions, one-way ANOVA and correlation.
Formula
power=1−Ft(t1−α/2;ν,δ)+Ft(−t1−α/2;ν,δ)ν=n1+n2−2δ=dn1n2/(n1+n2)
Example
d = 0.5, α = 0.05 two-sided, power 0.8: n = 64 per group (ν = 126, δ = 2.828, power 0.8015); with 63 per group power is 0.7952.

Last updated

FreeNo sign-upRuns in your browserData analysis

Loading Sample size calculator…

At a glance

Sample size calculator at a glance
TestsTwo-sample t, paired/one-sample t, two proportions, one-way ANOVA, correlation
Solves forSample size (smallest whole n) or power
DistributionsExact noncentral t (AS 243) and noncentral F; normal approximation for proportions; Fisher z for correlation
Optionsα, power, one- or two-sided, allocation ratio, continuity correction
Checkd=0.5, α=0.05, power 0.8 → 64 per group
Outputn per group and total, achieved power, critical value, noncentrality, power curve
Runs inYour web browser; nothing is uploaded
PriceFree, no account needed

What it does

How to use the sample size calculator

  1. Choose the testPick the analysis you will run: two-sample t, paired t, two proportions, one-way ANOVA or correlation, and whether to solve for n or for power.
  2. Enter the expected effectType an effect size (d, dz, f or ρ) or the expected means and SDs, proportions or group means from a pilot study or the literature.
  3. Set α and powerUsually α=0.05 two-sided and power 0.8 or 0.9; read off the sample size, the power curve and the sentence for your protocol.

How it works

t tests (exact). Under the alternative, the t statistic follows a noncentral t distribution with ν degrees of freedom and noncentrality δ. For two independent groups ν=n1+n2−2 and δ=d⋅n1n2/(n1+n2), where d=(μ1−μ2)/σ; for a paired (or one-sample) test ν=n−1 and δ=dz⋅n, where dz is the mean difference divided by the SD of the differences. Two-sided power is

1−β=1−Ft(t1−α/2,ν;ν,δ)+Ft(−t1−α/2,ν;ν,δ)

and one-sided power drops the last term and uses t1−α,ν. The noncentral t distribution function is computed with Lenth’s algorithm AS 243 (as in R’s pt). When entering means and SDs, d uses the pooled SD (SD12+SD22)/2.

One-way ANOVA. With k groups of n, the F statistic follows a noncentral F distribution with k−1 and k(n−1) degrees of freedom and noncentrality λ=f2⋅k⋅n, where Cohen’s f is the SD of the group means (divided by k) over the within-group SD.

Power=1−FF(F1−α;k−1,k(n−1),λ)

computed as a Poisson-weighted sum of incomplete beta functions. This is the convention of G*Power and R’s pwr.anova.test.

Two proportions. The normal approximation with the pooled proportion p¯=(p1+k⋅p2)/(1+k) under H0 and separate variances under H1 (n2=k⋅n1):

n1=[z1−α/2p¯q¯(1+1/k)+z1−βp1q1+p2q2/k]2/(p1−p2)2

The optional continuity correction is that of Fleiss, Tytun and Ury (1980):

n′=n4(1+1+2(k+1)n⋅k⋅|p1−p2|)2

Correlation. The Fisher z approximation used by R’s pwr.r.test: the critical r is found from the t distribution with n−2 degrees of freedom, and power=Φ((zρ−zrcrit)n−3) (plus the lower tail when two-sided), with zρ=atanhρ+ρ/(2(n−1)).

Sample size is the smallest whole n whose power reaches the target, found by search, so it already accounts for rounding and for the allocation ratio (n2=⌈k⋅n1⌉). Cohen’s conventional effect sizes: d=0.2,0.5,0.8; f=0.10,0.25,0.40; ρ=0.1,0.3,0.5 (small, medium, large). They are a last resort: an effect estimated from pilot data or the smallest effect that matters is better.

Checks. The distribution functions agree with SciPy’s nct and ncf to at least 10 significant figures. d=0.5 gives 64 per group (G*Power and pwr.t.test: 63.77 rounded up), dz=0.5 gives 34 pairs, f=0.25 with 3 groups gives 53 per group (159 in total), and ρ=0.3 gives 85 (pwr.r.test: 84.07 rounded up).

Sources: Cohen J. Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Hillsdale, NJ: Lawrence Erlbaum; 1988 (reissued by Routledge, doi:10.4324/9780203771587). Faul F, Erdfelder E, Lang A-G, Buchner A. G*Power 3: a flexible statistical power analysis program for the social, behavioral, and biomedical sciences. Behav Res Methods 2007;39:175–191, doi:10.3758/BF03193146. Lenth RV. Algorithm AS 243: cumulative distribution function of the non-central t distribution. Appl Stat 1989;38:185–189, doi:10.2307/2347693. Fleiss JL, Tytun A, Ury HK. A simple approximation for calculating sample sizes for comparing independent proportions. Biometrics 1980;36:343–346, doi:10.2307/2529990.

Worked examples: t test, ANOVA and two proportions

Two-sample t test. You expect treated cells to differ from controls by half an SD (d=0.5) and will test two-sided at α=0.05 with 80% power. With 64 per group, ν=126, the critical t is 1.9790 and δ=0.5×64×64/128=2.828, giving power 0.8015; with 63 per group power is 0.7952, so 64 per group (128 in total) is the answer. Entering means 10 and 12 with SDs of 4 gives the same d=2/4=0.5.

  • One-sided instead: 51 per group.
  • Power 0.9 instead of 0.8: 86 per group.
  • Twice as many in group 2 (ratio 2): n1=48, n2=96 (power 0.8021).
  • With only 20 per group, power is 33.8%.
Sample size per group for 80% power, α=0.05 two-sided
TestSmallMediumLarge
Two-sample t (d=0.2/0.5/0.8), per group3946426
Paired t (dz=0.2/0.5/0.8), pairs1993415
One-way ANOVA, 3 groups (f=0.10/0.25/0.40), per group3235322
Correlation (ρ=0.1/0.3/0.5), total7828529

One-way ANOVA. Three groups with f=0.25: with 53 per group (N=159) the F test has 2 and 156 degrees of freedom, critical F=3.054 and λ=0.252×159=9.94, so power is 0.8049 (52 per group gives 0.7967). Entering group means 10, 12 and 14 with a within-group SD of 6 gives f=1.633/6=0.272.

Two proportions. A response rate of 65% with the standard treatment and 85% expected with the new one, α=0.05 two-sided, power 0.8: n=72.4, so 73 per group (power 0.8033). With the Fleiss continuity correction it is 83 per group.

Frequently asked questions

How do I calculate sample size for a t test?

Decide the smallest difference worth detecting and the SD you expect, and divide to get Cohen’s d. With α=0.05 two-sided and 80% power, d=0.5 needs 64 per group, d=0.8 needs 26 and d=0.2 needs 394. The calculator finds the smallest n whose power, from the noncentral t distribution, reaches the target.

What sample size do I need for 80% power?

It depends on the effect size: for a two-sample t test at α=0.05 two-sided, 26 per group for a large effect (d=0.8), 64 for a medium effect (d=0.5) and 394 for a small effect (d=0.2). Smaller effects need many more participants because n scales roughly with 1/d2.

What is Cohen’s d and how do I estimate it?

d is the difference between the two means divided by the pooled SD. Estimate it from pilot data or published studies, or from the smallest difference that would matter in practice and the usual SD of the measurement. Cohen called 0.2, 0.5 and 0.8 small, medium and large, but those labels are only a fallback.

Should I use a one-sided or two-sided test?

Two-sided, unless a difference in the other direction would be of no interest and you decided this before collecting data. A one-sided test needs fewer participants (51 instead of 64 per group for d=0.5) but cannot detect an effect in the opposite direction.

Does this give the same answer as G*Power?

For t tests and one-way ANOVA it uses the same exact noncentral t and F distributions, so the sample sizes match: 64 per group for d=0.5, 34 pairs for dz=0.5 and 159 in total for f=0.25 with 3 groups. For correlation it uses the Fisher z method of R’s pwr.r.test, and for proportions the normal approximation; G*Power’s exact options for those can differ by a participant or two.

How do I account for dropouts?

Divide the calculated sample size by the proportion you expect to complete. For 64 per group and 15% dropout, recruit 64/0.85=75.3, so 76 per group.

What is the difference between power and α?

α is the chance of a false positive (rejecting H0 when there is no effect), usually 0.05. Power, 1−β, is the chance of detecting the effect if it is real, usually 0.8 or 0.9; β is the false-negative rate.

How many animals or replicates do I need per group?

Use the same calculation with the effect you expect relative to the variability between animals or replicates. For a large effect (d=0.8) a two-sample t test needs 26 per group for 80% power; for very large effects (d=1.5) it needs 9. Reporting guidelines such as ARRIVE ask you to state how the sample size was chosen.

Analyse the data when it arrives

The LabCanvas Graphs app runs t tests, ANOVA and correlations and draws the figure with the statistics on it.

Open the Graphs app