Answer

How many participants do I need for logistic regression?

A frequently asked statistics question ·

sample sizepower analysislogistic regression

The short answer

There is no single minimum. For a new prediction model, plan around the event rate, the number of candidate predictor parameters, and expected model fit. For a hypothesis about one odds ratio, plan around that coefficient, the predictor distribution, and the adjustment variables. Ten events per variable is a rough screening check, not a sample-size calculation.

Start with what the model must do

If the goal is to estimate an individual’s chance of an event, you are planning model development. You need enough information to keep predictions from overfitting and to estimate the overall risk. If the main question is whether one predictor is associated with the outcome after adjustment, you are planning for an effect estimate or test. These goals can lead to different sample sizes even when both analyses use logistic regression.

A third question is how much data you need to externally validate a model that is already fixed. That calls for precision targets for measures such as calibration or discrimination, not a development calculation or a test of a new coefficient.

Why ten events per variable is not enough

Count candidate parameters, not column names. A four-category predictor uses three coefficients; a nonlinear term or an interaction can add several more. Count the terms you plan to consider, not just the ones you expect to keep, and do not count the intercept as a predictor parameter.

For example, 300 complete observations with an expected 10% event rate yield about 30 events on average. Three candidate coefficients would put the expected ratio at 10 events per parameter. That does not tell you whether a rare category has enough cases or whether a predictor nearly separates events from non-events. Simulation evidence on the ten-event rule shows why the ratio alone is not a reliable threshold.

For prediction, limit overfitting and estimate overall risk

Riley and colleagues’ model-development method checks three things: sufficient expected shrinkage to limit overfitting (commonly target at least .90), a small expected gap between apparent and adjusted model fit, and enough precision for the overall event risk. Use the largest requirement, not just the one that gives the smallest sample.

In R’s pmsampsize package, use the binary-outcome option and specify the expected event proportion, the number of candidate parameters, and plausible anticipated Cox–Snell R². That R² is not ordinary linear-regression R² or Nagelkerke R². Use comparable external evidence when available and check a range of plausible prevalence and model-fit values rather than planning around one optimistic estimate.

For one coefficient, plan around the contrast

Specify the smallest odds ratio worth detecting, the unit of the predictor, a reference risk, the significance level, and target power. For an adjusted coefficient, also describe how the predictor and covariates are distributed, how strongly they overlap, and what outcomes those covariates predict. Use a method that matches the adjusted model, or simulate the planned analysis under plausible assumptions. For estimation rather than testing, set a target confidence-interval width.

Hsieh, Bloch, and Larsen show how planning for simple logistic regression with a binary predictor can start from a comparison of two proportions. Consider independent groups of equal size with risks p₀ and p₁. The equal-group normal approximation is n = (zα × √(2p̄(1−p̄)) + zβ × √(p₀(1−p₀)+p₁(1−p₁)))² / (p₁−p₀)², where p̄ is the average of the two risks, zα is the two-sided critical value, and zβ corresponds to target power. Round up per group. This example does not adjust for covariates or clustering.

R

p0 <- 0.20
p1 <- 0.30
p_bar <- (p0 + p1) / 2
a <- qnorm(1 - 0.05 / 2) * sqrt(2 * p_bar * (1 - p_bar))
b <- qnorm(0.80) * sqrt(p0 * (1 - p0) + p1 * (1 - p1))
per_group <- ceiling(((a + b) / (p1 - p0))^2)
c(per_group = per_group, total = 2 * per_group)

Python

from math import ceil, sqrt
from statistics import NormalDist

p0, p1 = 0.20, 0.30
p_bar = (p0 + p1) / 2
z = NormalDist().inv_cdf
a = z(1 - 0.05 / 2) * sqrt(2 * p_bar * (1 - p_bar))
b = z(0.80) * sqrt(p0 * (1 - p0) + p1 * (1 - p1))
per_group = ceil(((a + b) / (p1 - p0)) ** 2)
print({"per_group": per_group, "total": 2 * per_group})

The StatPower two-proportion calculator is another planning option for unadjusted independent groups. It uses a different normal approximation, based on Cohen’s h, so the counts can differ slightly. It is not a calculator for adjusted logistic regression. For sparse cells and separation, see the DASS Analysis Clinic’s logistic-regression case, which also links to its dissertation counterpart.

How to report logistic regression in APA style (7th edition)

In Methods, state whether the sample was planned for prediction, a coefficient test, or estimation. Report the assumptions, method, analyzable count, and how you allowed for missing outcomes. For an adjusted coefficient, name the predictor unit or reference group and the covariates. A results sentence can read: After adjustment for [covariates], [predictor contrast] was associated with the outcome, adjusted OR = [estimate], 95% CI [lower, upper], p = [value]. For prediction, report calibration and discrimination with uncertainty and say whether they were estimated on development or validation data.

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

Need more than an answer?

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.