Skip to main content

    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.

    Engine version 1.0.0 · Reviewed 1 October 2026

    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

    NN
    Number of participants
    p0, p1p_0,\ p_1
    Outcome probability without and with the predictor
    BB
    Share of participants with the predictor
    pˉ\bar{p}
    Overall outcome probability, (1 − B)p₀ + Bp₁
    RX∣Z2R^{2}_{X|Z}
    Share of the predictor’s variance explained by the other covariates
    α\alpha
    Significance level: the chance of a false positive
    1−β1-\beta
    Power: the chance of detecting the effect if it is real
    qq
    Expected dropout

    Formulas

    Outcome probability with the predictor

    p1=OR  p01+p0(OR−1)p_1 = \frac{\mathrm{OR}\;p_0}{1 + p_0(\mathrm{OR} - 1)}

    From the odds ratio and the probability without the predictor.

    Hsieh’s formula for a binary predictor

    N=⌈[z1−α/2pˉ(1−pˉ)/B+z1−βp0(1−p0)+p1(1−p1)(1−B)/B]2(p0−p1)2(1−B)⋅11−RX∣Z2⌉N = \left\lceil \frac{\left[z_{1-\alpha/2}\sqrt{\bar{p}(1-\bar{p})/B} + z_{1-\beta}\sqrt{p_0(1-p_0) + p_1(1-p_1)(1-B)/B}\right]^{2}}{(p_0 - p_1)^{2}(1-B)} \cdot \frac{1}{1 - R^{2}_{X|Z}} \right\rceil

    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

    nrecruit=⌈n1−q⌉n_{\text{recruit}} = \left\lceil \frac{n}{1 - q} \right\rceil

    Applied last, to the participants actually recruited.

    Parameters

    Odds ratio to detectOR\mathrm{OR}

    Values: Above 0, not 1

    The smallest odds ratio worth detecting.

    Outcome probability without the predictorp0p_0

    Values: Between 0 and 1

    Among those without the exposure, from routine data or previous studies.

    Share with the predictorBB

    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 covariatesRX∣Z2R^{2}_{X|Z}Optional

    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 tested11

    Values: One binary predictor

    Other covariates enter only through R²_X|Z.

    Significance levelα\alpha

    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.

    Power1−β1-\beta

    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 dropoutqqOptional

    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

    Protocol 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.

    Open this example in the calculator

    A less common exposure

    The same odds ratio with the exposure in 0.2 of participants: N = 512.

    Sample size: 512

    Protocol 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.

    Open this example in the calculator

    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

    Protocol 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.

    Open this example in the calculator

    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. 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. 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.