Skip to main content

    Method document

    Sample size for repeated measures: comparing rates of change (slopes)

    How many participants are needed in each of two groups, each measured repeatedly, to show that the groups change at different rates over time. Covers unequal groups, one- or two-sided tests and dropout.

    Engine version 1.0.0 · Reviewed 1 October 2026

    https://statwisely.com/methods/longitudinal-slopes/

    When to use it

    • A trial or cohort whose question is whether a treatment slows a decline or speeds a recovery, measured at several visits.

    Not for

    • Questions about the average level rather than the trajectory. Use the average level.

    Notation

    n1, n2n_1,\ n_2
    Participants in groups 1 and 2
    MM
    Measurements per participant
    σ\sigma
    Standard deviation of a single measurement
    ρm\rho_m
    Correlation between any two measurements on a participant
    Δ\Delta
    Difference to detect between the groups
    rar_a
    Allocation ratio n₂ / n₁
    TT
    Span of follow-up
    st2s_t^{2}
    Variance of the visit times
    α\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

    Variance of the difference in slopes

    Var⁡(Δ^)=σ2(1−ρm)M st2(1n1+1n2),st2=T2(M−1)2⋅M2−112\operatorname{Var}(\hat{\Delta}) = \frac{\sigma^{2}(1 - \rho_m)}{M\,s_t^{2}}\left(\frac{1}{n_1} + \frac{1}{n_2}\right), \qquad s_t^{2} = \frac{T^{2}}{(M-1)^{2}}\cdot\frac{M^{2} - 1}{12}

    A person’s own slope does not depend on where they started, so only the within-person variance σ²(1 − ρ) remains. Spreading visits over a longer span raises s_t² and helps as much as adding visits [1]. n₁ is the smallest whole number whose power on the noncentral t distribution, with n₁ + n₂ − 2 degrees of freedom, reaches the target.

    Dropout

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

    Applied last, to the participants actually recruited.

    Parameters

    Difference in rate of changeΔ\Delta

    Values: Not zero

    Per unit of the follow-up time, for example 0.3 points a year slower decline.

    Standard deviationσ\sigma

    Values: Above 0

    Of a single measurement, from previous data.

    Measurements per participantMM

    Values: At least 2

    Planned visits, equally spaced.

    Correlation between measurementsρm\rho_m

    Values: At least 0 and below 1

    How strongly a participant’s measurements track each other, from previous data.

    Follow-up spanTT

    Values: Above 0

    From the first to the last measurement, in the units of the rate of change.

    Allocation ratiorar_aOptional

    Values: Above 0; 1 for equal groups

    The planned size of group 2 divided by group 1.

    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

    • Compound symmetry: every pair of measurements on a participant is equally correlated. Other covariance structures, such as correlation that fades with time, can change power in either direction.
    • Every participant completes every visit; dropout is allowed for by recruiting more, not by modelling partial data.
    • Each participant’s trajectory is linear over the follow-up.
    • Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.

    Worked examples

    Five visits over four years

    A slope difference of 0.3 a year, SD 2, correlation 0.5, 5 visits over 4 years (s_t² = 2): 36 per group, 360 measurements in all.

    Group 1: 36 · Group 2: 36 · Total: 72

    Protocol statement

    To detect a difference in slope of 0.3 with 80% power at a two-sided significance level of 0.05, using a comparison of rates of change over 5 measurements spanning 4 units of time, and assuming a standard deviation of 2 and a correlation of 0.5 between measurements, the required sample size is 36 per group (72 in total). Calculated with StatWisely (statwisely.com) using: n₁: Var(Δslope)=σ²(1-r)/(m s_t²) × (1/n₁+1/n₂), solved on noncentral t. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    The same visits over eight years

    Spreading the five visits over 8 years quadruples s_t²: 10 per group.

    Group 1: 10 · Group 2: 10 · Total: 20

    Open this example in the calculator

    Nine visits over four years

    9 visits over the same four years: 25 per group, but 450 measurements.

    Group 1: 25 · Group 2: 25 · Total: 50

    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.

    How to cite

    StatWisely. Sample size for repeated measures: comparing rates of change (slopes). Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/longitudinal-slopes/

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

    References

    1. 1.Diggle PJ, Heagerty P, Liang KY, Zeger SL. Analysis of Longitudinal Data. 2nd ed. Oxford: Oxford University Press; 2002.