Statistical Calculators › Mixed Models and Longitudinal Data › Linear Mixed Model Sample Size (Random Slope)
← All Calculators

Mixed Models and Longitudinal Data

Linear Mixed Model Sample Size (Random Slope)

Sample size planning for a two-group longitudinal linear mixed model in which each subject has a subject-specific random slope. The calculation tests the treatment-by-time interaction, or equivalently the difference between the average slopes of the two groups.

Study Design

Enter the effect size, repeated-measures structure, variability, and desired power. The calculator finds the smallest Group 1 size that achieves the requested power.
An allocation ratio of 1.00 gives equal group sizes. A value of 2.00 means Group 1 has approximately twice as many subjects as Group 2. The this method formulation defines λ = K1 / K2.

Sample Size

The smallest integer Group 1 sample size for which the achieved power meets or exceeds the requested target.
Enter the study assumptions and click Calculate Sample Size.

Methodology

This calculator implements the two-level longitudinal mixed-model formulation used by this method for testing the difference between two group slopes when each subject has a random, subject-specific slope. The model includes fixed treatment, time, and treatment-by-time terms together with subject-specific random intercept and random slope terms.

Mixed Model

Yij = β0 + ξXi + τTij + δXiTij + υiTij + ui + eij

Here, δ is the difference between the two treatment slopes and is the parameter being tested. The random slope υi has variance σT2, while ρ describes the correlation among repeated measurements on the same subject.

Time Variability

this method assumes equally spaced measurements with time coded as T = 0, 1, …, M−1. The variance of the centered time values is

V(T) = Σ(Tj − T̄)2 / M = (M2 − 1) / 12

The random-slope variance is entered through rT = σT2 / σ2, where σ2 represents the variance associated with the fixed-slope model.

Power Formula

Let K1 and K2 be the numbers of subjects in Groups 1 and 2, respectively, and let λ = K1/K2. Under the normal approximation used by this method, power is calculated as

Power = Φ[ (δ/σ) √{ K2M V(T) / [(1 + λ−1) ((1 − ρ) + rTM V(T))] } − Φ−1(1 − α/2) ]

For sample-size determination, the calculator searches over integer Group 1 sample sizes. For each candidate K1, Group 2 is set to the smallest integer consistent with the requested allocation ratio, and the exact achieved power from the formula is checked. The reported design is the first one whose achieved power is at least the requested power.

Validation Example

the relevant methodological literature provides a sample-size example with 90% power, α = 0.05, four measurements per subject, a slope difference of 3, standard deviation 9.2, random-slope variance ratio rT = 0.1, within-subject correlation ρ = 0.5, and equal allocation. This yields 40 subjects in each group, 80 total, with achieved power 0.90335.

Power target = 0.90
α = 0.05
M = 4
δ = 3
σ = 9.2
rT = 0.10
ρ = 0.50
K1 = K2 = 40
Total N = 80
Achieved power = 0.90335

The implementation reproduces the this method result: with K1 = K2 = 40, calculated power is approximately 0.90335; reducing either group to 39 gives approximately 0.89614, below the 0.90 target. Thus 40 subjects per group is the smallest balanced design meeting the target.

Important Assumptions

References

Ahn, C., Heo, M., & Zhang, S. (2015). Sample Size Calculations for Clustered and Longitudinal Outcomes in Clinical Research. CRC Press, New York. Note that Chapter 5, Section 5.4.2, pages 161–164, as the source of the random-slope two-level longitudinal formulation.

the software, LLC. this method Sample Size Software, Chapter 383: Mixed Models Tests for the Slope Difference in a 2-Level Hierarchical Design with Random Slopes. the relevant methodological literature describes the model, power formula, worked examples, and validation against Ahn, Heo, and Zhang (2015).
View the this method Chapter 383 documentation

The this method procedure documentation explicitly describes this design as a two-level longitudinal study with random assignment of subjects to two groups, repeated measurements within subjects, and subject-specific random slopes. The documentation also reports the validation example used above.