Answer

How do you calculate the sample size needed to detect a correlation?

A frequently asked statistics question ·

correlationsample sizepower analysis

The short answer

Convert the correlation you want to detect to Fisher's z, z = atanh(r), then use n = ((z for alpha + z for power) / z)² + 3 and round up. For a two-sided test at α = .05 with 80% power, that gives 783 people for r = .1, 85 for r = .3 and 30 for r = .5. The hard part is not the arithmetic but choosing a realistic r.

The formula in one line

To plan a study that tests whether a Pearson correlation differs from zero, you need three inputs: the smallest correlation you care about detecting (r), the significance level (α, usually .05, two-sided) and the power you want (usually 80% or 90%). The standard approximation, based on Fisher's z transformation, is:

n = ((z_alpha + z_beta) / atanh(r))^2 + 3

Here atanh(r) is Fisher's z, which equals ½ ln((1 + r) / (1 − r)); z_alpha is the normal quantile for your significance level (1.96 for a two-sided test at α = .05); and z_beta is the normal quantile for your power (0.84 for 80%, 1.28 for 90%). Always round the result up to the next whole person.

The formula works because the sample correlation itself has an awkward, skewed sampling distribution, but its Fisher z is close to normal with a standard error of 1/√(n − 3) whatever the true correlation. That turns the problem into the familiar one for a normal mean: the expected z has to sit far enough from zero, measured in standard errors, to clear the critical value with the chosen probability.

A worked example, step by step

Suppose earlier work suggests a correlation of about .30 between two measures, and you want 80% power for a two-sided test at α = .05.

  1. Transform the correlation. atanh(0.30) = 0.3095.
  2. Add the two normal quantiles. 1.960 + 0.842 = 2.802.
  3. Divide and square. (2.802 / 0.3095)² = 81.93.
  4. Add 3 and round up. 81.93 + 3 = 84.93, so you need 85 complete pairs of observations.

Plan for missing data on top of that: if you expect 10% of participants to drop out or skip a measure, recruit 85 / 0.9, which is about 95. For a one-sided test, replace 1.960 with 1.645; only do that if a correlation in the other direction would genuinely be treated the same as a null result, and decide it before you see the data.

Sample size table for r = .1, .3 and .5

The R code below applies the formula to Cohen's conventional small, medium and large correlations, then checks two of the answers by simulation: it draws 10,000 samples of the planned size from a population with the target correlation and counts how often cor.test() gives p < .05. The Python tab does the same with NumPy and SciPy.

R

set.seed(2026)

# Sample size to detect a correlation r (two-sided test of rho = 0), Fisher z method
n_for_r <- function(r, power, alpha = 0.05) {
  z_alpha <- qnorm(1 - alpha / 2)     # 1.96 for alpha = .05
  z_beta  <- qnorm(power)             # 0.84 for 80% power, 1.28 for 90%
  ceiling(((z_alpha + z_beta) / atanh(r))^2 + 3)
}
r_values <- c(0.1, 0.3, 0.5)
table_n <- rbind(power_80 = sapply(r_values, n_for_r, power = 0.80),
                 power_90 = sapply(r_values, n_for_r, power = 0.90))
colnames(table_n) <- paste0("r=", r_values)
table_n

# Approximate power at a given n (same formula, solved the other way)
power_approx <- function(r, n, alpha = 0.05) {
  pnorm(atanh(r) * sqrt(n - 3) - qnorm(1 - alpha / 2))
}

# Simulation check: draw samples with true correlation r and run cor.test()
sim_power <- function(r, n, reps = 10000) {
  hits <- replicate(reps, {
    x <- rnorm(n)
    y <- r * x + sqrt(1 - r^2) * rnorm(n)
    cor.test(x, y)$p.value < 0.05
  })
  mean(hits)
}
check <- sapply(c(0.3, 0.5), function(r) {
  n <- n_for_r(r, 0.80)
  c(r = r, n = n, formula = power_approx(r, n), simulated = sim_power(r, n))
})
round(t(check), 3)

Python

import math
import numpy as np
from scipy import stats

rng = np.random.default_rng(2026)

# Sample size to detect a correlation r (two-sided test of rho = 0), Fisher z method
def n_for_r(r, power, alpha=0.05):
    z_alpha = stats.norm.ppf(1 - alpha / 2)   # 1.96 for alpha = .05
    z_beta = stats.norm.ppf(power)            # 0.84 for 80% power, 1.28 for 90%
    return math.ceil(((z_alpha + z_beta) / np.arctanh(r)) ** 2 + 3)

r_values = [0.1, 0.3, 0.5]
for power in (0.80, 0.90):
    print(f"power_{int(power * 100)}", {f"r={r}": n_for_r(r, power) for r in r_values})

# Approximate power at a given n (same formula, solved the other way)
def power_approx(r, n, alpha=0.05):
    return stats.norm.cdf(np.arctanh(r) * np.sqrt(n - 3) - stats.norm.ppf(1 - alpha / 2))

# Simulation check: draw samples with true correlation r and test it (same t test as cor.test)
def sim_power(r, n, reps=10000):
    x = rng.normal(size=(reps, n))
    y = r * x + np.sqrt(1 - r**2) * rng.normal(size=(reps, n))
    xc = x - x.mean(axis=1, keepdims=True)
    yc = y - y.mean(axis=1, keepdims=True)
    r_hat = (xc * yc).sum(axis=1) / np.sqrt((xc**2).sum(axis=1) * (yc**2).sum(axis=1))
    t = r_hat * np.sqrt((n - 2) / (1 - r_hat**2))
    p = 2 * stats.t.sf(np.abs(t), n - 2)
    return float(np.mean(p < 0.05))

for r in (0.3, 0.5):
    n = n_for_r(r, 0.80)
    print(f"r={r} n={n} formula={power_approx(r, n):.3f} simulated={sim_power(r, n):.3f}")
         r=0.1 r=0.3 r=0.5
power_80   783    85    30
power_90  1047   113    38
       r  n formula simulated
[1,] 0.3 85   0.800     0.802
[2,] 0.5 30   0.814     0.832

These figures come from one seeded run of the R code. The table involves no randomness, so Python gives the same sample sizes; its simulated power differs slightly because its random numbers differ from R's, but the pattern is the same.

Choosing the correlation to plan for

The formula is only as good as the r you feed it, and that choice moves the answer far more than the choice between 80% and 90% power.

If your goal is to estimate the correlation precisely rather than to test it against zero, plan for the width of the confidence interval instead: on the z scale the 95% interval is roughly ±1.96/√(n − 3), so an interval of ±0.1 on that scale needs about 388 people regardless of the correlation's size. Power for other designs is covered on our page on whether a t test needs a minimum sample size, and the DASS tools page has calculators if you prefer not to code it.

How to report a sample size calculation in APA style (7th edition)

In the method section, give every input someone would need to repeat the calculation: the target correlation and where it came from, α, sidedness, power, the method or software, and the resulting n. Using the worked example:

"An a priori power analysis based on Fisher's z approximation indicated that 85 participants were needed to detect a correlation of r = .30 with 80% power in a two-sided test at α = .05. The target correlation was taken from [source]. Allowing for 10% attrition, we aimed to recruit 95 participants."

In the results, report the observed correlation with its degrees of freedom and confidence interval, for example r(83) = .xx, 95% CI [LL, UL], p = .xxx, so readers can see how precisely it was estimated.

Related tools and guides

More answered questions

Working with your own data?

General answers only go so far. Send us your situation and we'll reply by email within two business days.

Ask your question

Written by AskStats with AI assistance. This is general information, not advice for your specific data or study. When the results matter, check your approach with a qualified statistician.