Method document
Sample size for logistic regression with a binary predictor
How many participants are needed to show that a binary predictor is associated with a binary outcome in a logistic regression, from the odds ratio, the outcome probability without the predictor, and how common the predictor is. Allows for other covariates. Covers dropout.
https://statwisely.com/methods/regression-logistic/
When to use it
- A cohort or cross-sectional study analysed with logistic regression, testing whether a yes/no exposure is associated with a yes/no outcome.
Not for
- A numerical predictor. Use logistic regression with a numerical predictor.
- A case-control design with a fixed ratio of cases to controls. Use the odds ratio.
Notation
- Number of participants
- Outcome probability without and with the predictor
- Share of participants with the predictor
- Overall outcome probability, (1 − B)p₀ + Bp₁
- Share of the predictor’s variance explained by the other covariates
- Significance level: the chance of a false positive
- Power: the chance of detecting the effect if it is real
- Expected dropout
Formulas
Outcome probability with the predictor
From the odds ratio and the probability without the predictor.
Hsieh’s formula for a binary predictor
Powers the test of the logistic coefficient for a binary predictor carried by a share B of one sample [1]. The last factor inflates the sample for other covariates, according to how well they predict this one.
Dropout
Applied last, to the participants actually recruited.
Parameters
Odds ratio to detect
Values: Above 0, not 1
The smallest odds ratio worth detecting.
Outcome probability without the predictor
Values: Between 0 and 1
Among those without the exposure, from routine data or previous studies.
Share with the predictor
Values: Between 0 and 1
How common the exposure is in the sample. A rare exposure needs a larger sample.
R² of the predictor on the other covariatesOptional
Values: At least 0 and below 1; 0 with no other covariates
How well the other covariates predict this exposure. Strongly related covariates cost power.
Predictor tested
Values: One binary predictor
Other covariates enter only through R²_X|Z.
Significance level
Values: Between 0 and 1; usually 0.05
The false-positive rate you accept. A smaller α, for example to allow for several primary outcomes, needs a larger sample.
Power
Values: Between 0 and 1; usually 0.80 or 0.90
The chance of a significant result if the assumed effect is real. Funders and ethics committees commonly expect at least 0.80.
Expected dropoutOptional
Values: 0% up to, but not including, 100%
The share of participants expected to provide no outcome, from comparable studies. Recruiting more restores the numbers, not the comparability of the groups: if dropout is related to the outcome, the estimate can still be biased.
Assumptions
- Participants are independent, and the predictor is binary.
- The test is the Wald test of the coefficient, two-sided.
- Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.
Worked examples
An exposure in half the sample
OR = 2 on a baseline of 0.2, so p₁ = 0.333, with the exposure in 0.5 of participants: N = 343.
Sample size: 343
Open this example in the calculatorProtocol statement
To detect an odds ratio of 2 with 80% power at a two-sided significance level of 0.05, using a logistic regression with a binary predictor, and assuming an outcome probability of 20% without the predictor and the predictor present in 50% of participants, the required sample size is 343 participants. Calculated with StatWisely (statwisely.com) using: Hsieh binary covariate: N=[z_(1-α/2)√(p̄(1-p̄)/B)+z_(1-β)√(p₀(1-p₀)+p₁(1-p₁)(1-B)/B)]²/[(p₀-p₁)²(1-B)]/(1-R²_X|Z). These are planning estimates; confirm the final design with a qualified statistician.
A less common exposure
The same odds ratio with the exposure in 0.2 of participants: N = 512.
Sample size: 512
Open this example in the calculatorProtocol statement
To detect an odds ratio of 2 with 80% power at a two-sided significance level of 0.05, using a logistic regression with a binary predictor, and assuming an outcome probability of 20% without the predictor and the predictor present in 20% of participants, the required sample size is 512 participants. Calculated with StatWisely (statwisely.com) using: Hsieh binary covariate: N=[z_(1-α/2)√(p̄(1-p̄)/B)+z_(1-β)√(p₀(1-p₀)+p₁(1-p₁)(1-B)/B)]²/[(p₀-p₁)²(1-B)]/(1-R²_X|Z). These are planning estimates; confirm the final design with a qualified statistician.
Adjusting for related covariates
If the other covariates explain 0.3 of the exposure’s variance: 343 / (1 − 0.3) = 490, so N = 490.
Sample size: 490
Open this example in the calculatorProtocol statement
To detect an odds ratio of 2 with 80% power at a two-sided significance level of 0.05, using a logistic regression with a binary predictor, and assuming an outcome probability of 20% without the predictor, the predictor present in 50% of participants and other covariates explaining 0.3 of its variance, the required sample size is 490 participants. Calculated with StatWisely (statwisely.com) using: Hsieh binary covariate: N=[z_(1-α/2)√(p̄(1-p̄)/B)+z_(1-β)√(p₀(1-p₀)+p₁(1-p₁)(1-B)/B)]²/[(p₀-p₁)²(1-B)]/(1-R²_X|Z). These are planning estimates; confirm the final design with a qualified statistician.
Validation
- Every worked example on this page is recomputed by the StatWisely engine whenever the software is built. If a number or formula here stopped matching the calculator, the release would be stopped until this document was corrected.
- An independent implementation in R recomputes this test every night and before each production release, and the results are compared with the engine’s.
- For the binary-predictor example in the G*Power manual (outcome probability 0.05 rising to 0.10, predictor in half the sample, α = 0.05, 95% power), StatWisely gives the published 1,437 [2].
How to cite
StatWisely. Sample size for logistic regression with a binary predictor. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/regression-logistic/
Cite the original references for the formulas your design uses as well.
References
- 1.Hsieh FY, Bloch DA, Larsen MD. A simple method of sample size calculation for linear and logistic regression. Statistics in Medicine. 1998;17(14):1623–1634.
- 2.Faul F, Erdfelder E, Lang AG, Buchner A. G*Power 3: a flexible statistical power analysis program for the social, behavioral, and biomedical sciences. Behavior Research Methods. 2007;39(2):175–191.