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.
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
- Participants in groups 1 and 2
- Measurements per participant
- Standard deviation of a single measurement
- Correlation between any two measurements on a participant
- Difference to detect between the groups
- Allocation ratio n₂ / n₁
- Span of follow-up
- Variance of the visit times
- Significance level: the chance of a false positive
- Power: the chance of detecting the effect if it is real
- Number of tails: 2 for a two-sided test, 1 for one-sided
- Expected dropout
Formulas
Variance of the difference in slopes
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
Applied last, to the participants actually recruited.
Parameters
Difference in rate of change
Values: Not zero
Per unit of the follow-up time, for example 0.3 points a year slower decline.
Standard deviation
Values: Above 0
Of a single measurement, from previous data.
Measurements per participant
Values: At least 2
Planned visits, equally spaced.
Correlation between measurements
Values: At least 0 and below 1
How strongly a participant’s measurements track each other, from previous data.
Follow-up span
Values: Above 0
From the first to the last measurement, in the units of the rate of change.
Allocation ratioOptional
Values: Above 0; 1 for equal groups
The planned size of group 2 divided by group 1.
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.
One- or two-sided
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 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
- 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
Open this example in the calculatorProtocol 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.
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 calculatorNine 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 calculatorValidation
- 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.Diggle PJ, Heagerty P, Liang KY, Zeger SL. Analysis of Longitudinal Data. 2nd ed. Oxford: Oxford University Press; 2002.