Skip to main content

    Method document

    Sample size to detect a change over time in a repeated binary outcome

    How many participants, each measured repeatedly, are needed to show that the probability of a yes/no outcome changes over time in one group, from the outcome probability, the odds ratio per unit of time, the visit schedule and the correlation between a participant’s measurements. Uses logistic GEE with an exchangeable correlation. Covers dropout.

    Engine version 1.0.0 · Reviewed 4 October 2026

    https://statwisely.com/methods/longitudinal-binary-trend/

    When to use it

    • A cohort with a yes/no outcome recorded at every visit, testing whether it becomes more or less common over follow-up.

    Not for

    • Comparing how two groups change. That needs a group-by-time interaction and its own calculation.
    • Participant-specific effects from a logistic mixed model, which differ from population-average ones.

    Notation

    nn
    Number of participants
    pp
    Outcome probability at the middle of follow-up
    OR\mathrm{OR}
    Odds ratio per unit of time to detect
    m, Tm,\ T
    Measurements per participant, equally spaced over a follow-up of length T
    ρ\rho
    Correlation between two measurements on the same participant
    V(β)V(\beta)
    Per-participant variance of the GEE time slope
    α\alpha
    Significance level: the chance of a false positive
    1−β1-\beta
    Power: the chance of detecting the effect if it is real
    τ\tau
    Number of tails: 2 for a two-sided test, 1 for one-sided
    qq
    Expected dropout

    Formulas

    Wald test of the GEE time slope

    n=⌈(z1−α/s+z1−β)2 V(β)(ln⁡OR)2⌉,V(β)=[(D⊤V−1D)−1]ββn = \left\lceil \frac{(z_{1-\alpha/s} + z_{1-\beta})^{2}\, V(\beta)}{(\ln \mathrm{OR})^{2}} \right\rceil, \qquad V(\beta) = \left[(D^{\top} V^{-1} D)^{-1}\right]_{\beta\beta}

    V(β) is the model-based GEE variance over the schedule at the expected odds ratio, with D = A X, V = A^{1/2} R(ρ) A^{1/2} and A = diag(μ(1 − μ)) at each visit, the exchangeable working correlation being taken as the true one [1]. With a small change it is (1 − ρ)/[p(1 − p) m s_t²] [2].

    Dropout

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

    Applied last, to the participants actually recruited.

    Parameters

    Outcome probability at the middle of follow-uppp

    Values: Between 0 and 1

    From routine data or a previous cohort.

    Odds ratio per unit of timeOR\mathrm{OR}

    Values: Above 0, not 1

    In the unit the follow-up is entered in.

    Measurements per participantmm

    Values: A whole number of at least 2

    Equally spaced over the follow-up.

    Follow-up lengthTT

    Values: Above 0

    A longer follow-up spreads the visits and strengthens the test.

    Correlation between measurementsρ\rho

    Values: At least 0 and below 1

    On the binary scale, the same for every pair of visits.

    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.

    One- or two-sidedτ\tau

    Values: 2 (two-sided) or 1 (one-sided)

    Two-sided is the default. A one-sided test is justified only when an effect in the other direction would be treated exactly as no effect, and should be stated in advance.

    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; a participant’s measurements share one correlation (exchangeable); visits are equally spaced, every participant attends them all, and the log odds change linearly with time.
    • Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.

    Worked examples

    Four visits over three years

    p = 0.3, OR = 1.3 per year, ρ = 0.5, two-sided α = 0.05, 80% power: n = 57.

    Sample size: 57

    Protocol statement

    To detect an odds ratio of 1.3 per unit of time with 80% power at a two-sided significance level of 0.05, using a logistic GEE test of change over time in one group with 4 measurements, and assuming an outcome probability of 30% at the middle of follow-up and a correlation of 0.5 between a participant’s measurements, the required sample size is 57 participants. Calculated with StatWisely (statwisely.com) using: n = (z_(1-α/tails)+z_(1-β))² × V(β) / (ln OR)², V(β) the exchangeable GEE variance over m visits. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    More visits over the same period

    7 visits over the same three years: n = 41.

    Sample size: 41

    Open this example in the calculator

    Allowing for dropout

    Expecting 20% to drop out: 57 / 0.8 = 71.3, so 72 are enrolled.

    Needed for analysis: 57 · To recruit: 72

    Protocol statement

    To detect an odds ratio of 1.3 per unit of time with 80% power at a two-sided significance level of 0.05, using a logistic GEE test of change over time in one group with 4 measurements, and assuming an outcome probability of 30% at the middle of follow-up and a correlation of 0.5 between a participant’s measurements, the required sample size is 57 participants. Allowing for 20% dropout, 72 participants should be recruited. Calculated with StatWisely (statwisely.com) using: n = (z_(1-α/tails)+z_(1-β))² × V(β) / (ln OR)², V(β) the exchangeable GEE variance over m visits. 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.
    • Simulating 1,000 cohorts of 57 participants in R, with correlated binary outcomes from a Gaussian copula calibrated to ρ = 0.5 and analysed with geepack::geeglm, gave power of 0.812 against a target of 0.80. An independent R computation of the GEE variance reproduces the engine’s sizes.

    How to cite

    StatWisely. Sample size to detect a change over time in a repeated binary outcome. Method document, engine version 1.0.0, reviewed 2026-10-04. https://statwisely.com/methods/longitudinal-binary-trend/

    Cite the original references for the formulas your design uses as well.

    References

    1. 1.Liu G, Liang KY. Sample size calculations for studies with correlated observations. Biometrics. 1997;53(3):937–947. doi:10.2307/2533554
    2. 2.Diggle PJ, Heagerty P, Liang KY, Zeger SL. Analysis of Longitudinal Data. 2nd ed. Oxford: Oxford University Press; 2002.