I’m analyzing longitudinal data with three timepoints:
- Time 0 = baseline
- Time 12 = post-treatment
- Time 24 = follow-up
Because the treatment occurs at Time 12, I’m modeling a potential change in trajectory using a piecewise linear fixed-effects structure with a knot at 12:
time1 <- pmin(time, 12)
time2 <- pmax(0, time - 12)
What I want to fit is:
- Fixed effects: time1 and time2 (two slopes, one per segment)
- Random effects: only one random linear slope for the overall continuous time variable
- I do not want (nor can I estimate) separate random slopes for each piece, because I only have three timepoints
Example model:
model_piecewise <- lmer(
BDI ~ time1 + time2 +
(1 + time | id),
data = dat
)
My questions:
Is this model specification statistically legitimate? I have two fixed slopes (piecewise), but allow subjects to vary only in a single random linear slope (i.e. the overall time of the study, week 0, 12 and 24).
Is there any requirement in mixed-model theory or in
lmer()that random slopes must match the fixed-effects structure (i.e., one random slope per piece)?Given only three measurement occasions, estimating two random slopes (for time1 and time2) is impossible. Is the above model the correct way to include subject-level slope variability without overspecifying the random structure?
Are there papers or examples where piecewise fixed effects are combined with only one random linear slope of overall time?