Discontinuous splines?

Hello!

I’m trying to model symptom trajectories in a dataset of people who have decided to discontinue psychiatric medication. There are 3-5 irregularly spaced observations per person. People discontinue medication at different times, but everyone discontinues eventually.

Exploratory plotting suggests that symptom trajectories (both before and after discontinuation) are often very non-linear, so a dummy variable capturing level change is probably not enough.

My first thought was to represent change over time using splines like this:

brm(symptoms ~ s(time, off_meds, bs = "fs", k = 10) +  (1|clinic) + (1|patient))

However, my fit is difficult to take seriously.

Here’s the model fit for an imaginary person who stays “on meds” for the duration of the study alongside an imaginary person who stays “off meds” for the duration:

There are (by definition) no observations for anyone off meds at admission, and yet the model is very confident (these are 90 percent credible intervals) that a person off meds at baseline has lower symptoms than a person on meds at baseline. That seems wrong.

Perhaps the solution is to ignore predictions for people off meds during the first few months of treatment, just as one might ignore model predictions for human heights over 10 feet? So I plotted out what the same model implies about a person who stays on meds until 7 months and then goes off medication, comparing that to a counterfactual person who stays on meds for the duration of the study, like this:

One interpretation of this second graph is that people going off meds tend to get initially worse but then gradually bring themselves under control.

Another interpretation is that the model is fitting separate curves for the “on meds” and “off meds” data points, has zero observations of people who are “off meds” at the beginning of the study, and very few observations of people who are “on meds” at the end of the study, and so the whole fitting process is getting thrown off.

I’m curious if others have been in a similar situation before, and if there’s a way to better model this process. I’m worried the solution is some kind of weird discontinuous spline, e.g. letting one spline fit to all the data up until medication discontinuation, and letting the other spline fit to all the data starting from medication discontinuation. I suppose I could hard-code this in Stan, but am hoping there’s some solution within a package like brms or rstanarm.

I’d appreciate any insight people may have.

Splines can be useful in a discontinuity analysis, and you’ll want to focus on differences in prediction at or near the point of change or discontinuity. If your data and context allows, instead of modeling months directly,would it be useful to, for each person, subtract their time of discontinuity (stopping meds?) so that time for all in the study represents time until through time elapsed since stopping meds?

I think both (1) time to/from discontinuation and (2) time since admission are really meaningful. People are admitted to the program for a first psychotic episode, and so there tends to be rapid improvement around admission (because people are finally getting treatment and/or simply returning to baseline).

So maybe one spline for time since admission, and one spline for time since medication discontinuation? Maybe that’s enough to capture the whole process…

Have you encountered the lgpr package? Qualitatively what you seem to be interested in quantifying echoes the package tutorials, so might be of use/interest. At the very least, they might suggest some useful paths forward outside of the package. Note lgpr uses Gaussian process models, a very particular flavor of spline, but GPs are well-suited to handling the temporal correlations implied by irregularly spaced measurements over time.

At @avehtari first turned me on to this package when I was bumbling through some initial experiments by GPs using brms. Good luck!

2 Likes

This package looks great! Thank you!!