Home / Tools / Sample Size for ANOVA

Sample Size Calculator for ANOVA

Planning a study that compares three or more groups? This works out how many people you need in each one. Tell it how big a difference you want to be able to detect, either as Cohen's f or as the group means and a common standard deviation you expect, and it returns the sample size that gives you a real chance of finding it. It also runs backwards: give it the sample you can afford and it tells you the power you would have, or the smallest effect you could catch.

Part of the sample-size family: all sample size calculators.

I want to size a study on several groups

Try:
Effect you want to detect
Design

Power 0.80 and alpha 0.05 are the usual defaults. Nothing you type leaves your browser.

One-way ANOVA, 4 groups

Recruit 45 per group

180 participants in total.

45 per group · 180 total
What if you compared a different number of groups… 4 groups → 45 per group, 180 total
Exact n
44.599
Power at that n
0.8032
Cohen's f
0.25
Eta-squared
0.059
What this means
How this number is computed
The same thing in R

No data leaves your browser Verified against R's pwr.anova.test() and power.anova.test() Free, no sign-up

What actually moves the number

Sample size is driven by the effect you want to catch far more than by anything else. This table is live: it recomputes for your current number of groups and alpha.

Effect size80% power90% power95% power

The pattern to take away: required n scales with roughly 1/f². Halving the effect you want to detect does not double the sample, it roughly quadruples it. Chasing more power is comparatively cheap, and tightening alpha sits somewhere in between. If a study looks unaffordable, the honest lever is almost always a more precise measurement, which raises f by shrinking the within-group SD, rather than a bigger budget.

Cohen's f, and what it has to do with eta-squared

Two names for the same information, and the calculator will take either.

Cohen's f is the standard deviation of your group means divided by the standard deviation inside the groups. So it asks: how far apart are the group means, measured in units of ordinary within-group noise? An f of 0.25 means the means are spread out by a quarter of a within-group SD.

Eta-squared answers a different-sounding question: of all the variation in your outcome, what share is explained by which group someone is in? It is a proportion, so it lands between 0 and 1 and is often quoted as a percentage.

These are two views of one quantity, and you can convert freely between them:

Going this wayFormula
Eta-squared to ff = √(η² / (1 − η²))
f to eta-squaredη² = f² / (1 + f²)

The intuition behind the formula is worth a moment. Eta-squared is explained variance over total variance. Cohen's f is the ratio of explained spread to unexplained spread. So f compares the signal to what is left over, while eta-squared compares the signal to everything. That is why f can grow without limit while eta-squared can never reach 1: as the groups separate, the leftover noise shrinks toward nothing, and dividing by an ever-smaller number sends f upward.

Cohen's benchmarks, and why they are only a starting point

Cohen proposed 0.10, 0.25 and 0.40 as small, medium and large for f, and the field adopted them.

Cohen's fLabelEta-squaredVariance explainedn per group, 3 groups, 80% power
0.10Small0.0099About 1%323
0.25Medium0.0588About 6%53
0.40Large0.1379About 14%22

Look at what "large" actually means here: an effect Cohen called large explains about 14% of the variance, leaving 86% unexplained. That is a useful corrective to the word.

Cohen intended these as a fallback for when nothing better was available, and warned against treating them as universal. They came from behavioural research, where an f of 0.40 is genuinely big. In other fields the same number means something else entirely: an f of 0.05 in a large agricultural trial can be worth a great deal of money, while an f of 1.0 in a tightly controlled calibration experiment may be unremarkable. Domain context beats the benchmark every time. The better question is not "is this small or medium" but "what is the smallest difference between these groups that would change what I do?" Answer that, put it in as means and an SD, and you have your f.

Adding groups is not free

At a fixed f, more groups means fewer people per group but more people overall. This table is live for your current f and alpha.

Groups (k)n per groupTotal Nvs 2 groups

Per-group n falls because the F test pools the within-group noise from every group: more groups means more degrees of freedom for the error term, so each group can be a little smaller. But the total climbs, because you are paying for those extra groups. The numerator degrees of freedom also grow with k, which raises the critical value and works against you.

One caution about reading this table. Holding f fixed while you add groups is a strong assumption, and often the wrong one. Cohen's f is the spread of your group means, so a new group that lands near the grand mean actively lowers f and pushes the cost up, while a new extreme group raises f and pulls it down. If you are genuinely deciding between three arms and six, do not read a column off this table: put in the means you actually expect for each design and compare the answers.

Two groups: the same test you already know

A one-way ANOVA on two groups is not similar to the two-sample t test. It is the same test.

With k = 2 the ANOVA F statistic is exactly the square of the two-sample t statistic, and an F test with 1 numerator degree of freedom is precisely the two-sided t test. The effect sizes line up too: when there are only two means, the spread of the means is half the gap between them, so f = d / 2.

That gives you a free check on both calculators. Ask this page for two groups at f = 0.25, 80% power, alpha 0.05, and it returns 64 per group. Ask the t test calculator for d = 0.5 with the same settings and it also returns 64. The exact roots agree to nine decimal places, because underneath they are solving the same equation. The "2 groups" chip above sets this up if you want to watch it happen.

The practical consequence: if you have exactly two groups, use the t test calculator. It gives the same answer, and it also lets you choose a one-tailed test and an unequal allocation ratio, neither of which the omnibus F test offers.

Why pwr and power.anova.test look different but agree

R ships two ways to do this, and they appear to disagree until you see which variance each one wants.

pwr::pwr.anova.test takes Cohen's f and builds its noncentrality parameter as λ = k × n × f². Base R's stats::power.anova.test never mentions f: it asks for a between.var and a within.var, and builds λ = (k − 1) × n × (between.var / within.var). Different inputs, different formula, and the (k − 1) out front where pwr has a k.

They are the same calculation. The reconciliation hides in a denominator. Cohen's f uses the population spread of the means, dividing the sum of squared deviations by k. R's var() is a sample variance, dividing by k − 1. So when you pass between.var = var(means), you are handing power.anova.test a number that is already k/(k−1) times bigger than f²:

QuantityValue
Cohen's f²Σ(mᵢ − m̄)² / k ÷ σ²
var(means) / σ²Σ(mᵢ − m̄)² / (k−1) ÷ σ² = f² × k/(k−1)
power.anova.test's λ(k−1) × n × f² × k/(k−1) = k × n × f²

The (k − 1) cancels, and you are left with pwr's λ exactly. Both functions also use the same degrees of freedom, k − 1 and (n − 1) × k. Feed them matching inputs and they return the same n to the last digit their solvers can resolve. The R block above emits both routes for you, so you can run them side by side.

Where this bites: if you compute between.var yourself by dividing by k rather than using var(), power.anova.test will quietly understate your effect and hand back a sample size that is too large. Use var(means) and let the cancellation do its job.

What this calculation assumes

AssumptionWhat it meansIf it is wrong
Balanced designEvery group has the same nUnequal groups have less power than the same total split evenly, so this becomes optimistic
Equal variancesOne common within-group SDThe F test is sensitive to this when groups are unbalanced; consider Welch's ANOVA
Independent observationsNo repeated measures, no clusteringClustered data needs a design effect; repeated measures needs a different model entirely
Normal residualsWithin-group noise is roughly GaussianMild skew is tolerable at these sample sizes; heavy tails are not
Omnibus questionYou are testing "are the means all equal?"If you want specific pairwise contrasts, size for those instead, with alpha adjusted

The last row is the one people get caught by. An ANOVA powered at 80% for the omnibus test is not powered at 80% for the follow-up comparisons that everyone actually wants to report, because those carry a multiple-comparison correction on top. If a specific pair is your real question, plan for that pair.

Questions people ask

How many participants per group does a one-way ANOVA need?

It depends almost entirely on Cohen's f. To detect a medium effect (f = 0.25) across three groups with 80% power at alpha = 0.05, you need 53 per group, so 159 in total. Drop to a small effect (f = 0.10) and it jumps to 323 per group, nearly a thousand people. Sample size scales with roughly 1/f², which is why small effects are so expensive to study.

What is Cohen's f and how does it relate to eta-squared?

Cohen's f is the SD of the group means divided by the SD within groups, so it measures how far apart the means are in units of within-group noise. Eta-squared is the share of total variance explained by the grouping. They carry the same information: f = √(η²/(1−η²)) and η² = f²/(1+f²). Cohen's f benchmarks of 0.10, 0.25 and 0.40 are eta-squared of about 1%, 6% and 14%. This page takes either one: use the buttons above the effect field.

Why does pwr.anova.test use f while power.anova.test uses variances?

They are the same calculation in different clothes. pwr builds its noncentrality from k × n × f²; power.anova.test builds it from (k−1) × n × (between.var/within.var). Cohen's f divides the squared mean deviations by k, while R's var() divides by k−1, so between.var/within.var equals f² × k/(k−1). Multiply by the (k−1) out front and you get k × n × f², which is pwr exactly. Pass between.var = var(means) and within.var = sd^2 and the two agree.

Does a one-way ANOVA on two groups match the two-sample t test?

Yes, exactly. With two groups the ANOVA F is the square of the two-sample t, and an F test with 1 numerator df is the two-sided t test. The effect sizes match too: f = d/2 when k = 2. So f = 0.25 with two groups needs 64 per group at 80% power and alpha 0.05, the same number the t test calculator gives for d = 0.5. If you really do have two groups, use that page: it also offers one-tailed tests and unequal allocation.

What happens to sample size when I add more groups?

At a fixed f, adding groups lowers n per group but raises the total: 3 groups at f = 0.25 and 80% power needs 53 each (159 total), while 6 groups needs 36 each (216 total). Watch it live with the slider above. But holding f fixed while adding groups is a strong assumption, because f depends on the spread of the means. A new group near the grand mean lowers f and raises the cost. If you are choosing between designs, enter the means you actually expect for each and compare.

Is 80% power always the right target?

80% is a convention, not a rule. It means that if the effect really is the size you assumed, you still miss it one time in five. If a missed effect is expensive, 90% or 95% is common in confirmatory work. Going from 80% to 90% costs about a third more per group; 95% costs about two thirds more. You can watch that trade-off directly in the live table above.

My ANOVA is significant. Which groups actually differ?

The omnibus F test only tells you the means are not all equal. It does not say which pair differs, and a study powered for the omnibus test is usually underpowered for the pairwise comparisons that follow, since those need a multiple-comparison correction. If specific contrasts are your real question, size the study on the pairwise effect with the t test calculator and adjust alpha with the multiple testing correction tool.

My calculated n is fractional. Do I round up or down?

Always up. pwr.anova.test returns the exact point where power equals your target, for example 52.32. Rounding down to 52 leaves you below target power; rounding up to 53 puts you just above it. This page shows both: the exact value, and the power your rounded-up integer actually delivers, which is always a little more than you asked for.