Suppose we have a regression / survival model where we would like to model follow-up time using a regression spline. Follow-up time has two phases (first treatment active, and second treatment completed i.e. not active) which we would like to consider i.e. allow for slope changes. However, the time points at which these phases occur can differ by subject (person). How can we construct the spline for time so that the slope can change as the subject passes from the first to second phase? Do we need to place a knot at this boundary but allow it to vary by subject?
Update (further details as requested)
I was wondering if this approach is possible to use in regression / survival models in general. Hence I just used the unit of person. However, the current study for which I would like to consider this approach is a longitudinal study modeling counts (rates) over time. We have monthly counts by sex for several months before start of intervention (I.e. baseline), during intervention (i.e. active phase), and after intervention (i.e. post phase), in paired control and treatment sites. I had planned to use mean (since we have several months worth-) of “before” as baseline covariate as per ANCOVA approach. So the model will look roughly like:
Post = offset + baseline + month + sex + treatment + phase + time_since_start_active + time_since_start_post + (1|pair/clinic)
Where: month is categorical to adjust for natural monthly changes, treatment is yes/no indicating whether site is real intervention or control, phase is active/post. The time terms are numeric which I would like to model with splines. The terms in brackets are random effects.
The timeline is the same within but not between pairs of clinics. In other words, the lengths of active and post phases might differ between pairs of clinics. That’s why I was considering two time variables that I wondered if these could be constructed together in one spline term?
I am also aware of the need for interaction terms in the above model. In particular, I think there is a need to include random slopes for time variables since duration of phase might alter its slope?