stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
379 stars 134 forks source link

[QUESTION] `posterior_traj()` for `stan_mvmer` #591

Open frbrz opened 1 year ago

frbrz commented 1 year ago

Summary:

Is it possible to make dynamic prediction for a multivariate mixed model without the survival component?

Description:

Hi, thanks for developing rstanarm and stan! I am interested in modelling two longitudinal continuous outcomes (without any survival component). I can fit the model I am interested with using stan_mvmer (see steps below). Now I am interested in obtaining dynamic predictions, as it can be done for a stan_jm object using the post_traj function. I think (!) that it should be possible to obtain longitudinal dynamic predictions for a multivariate mixed model, but at the moment post_traj only accepts stan_jm objects. Would it be possible to extend post_traj?

Reproducible Steps:

fit <- stan_mvmer(
  formula = list(
    Y1 ~ TIME + BL1 + (TIME | PATNUM),
    Y1 ~ TIME + BL2  + (TIME | PATNUM)
  ),
  data = train_df, 
  # this next line is only to keep the example small in size!
  chains = 2, cores = 2, seed = 12345, iter = 1000
)

RStanARM Version:

2.21.3

R Version:

4.2.0

Operating System:

x86_64-pc-linux-gnu (64-bit)

Thanks for the help, best wishes Francesco

sambrilleman commented 1 year ago

Hi Francesco

Yeah sorry I imagine it wasn't implemented as a bit of an oversight more than anything. Because I developed stan_jm as part of a Phd in joint modelling, stan_jm was treated as somewhat of a first class citizen, whilst stan_mvmer was more of a building block for stan_jm and so probably didn't get implemented as comprehensively. ☹️

I'm a bit too long out of these details to remember exactly what limitations there might or might not be, but I think you are right in the sense that you should be able to take the fitted model, and then some newly observed data for a new individual, and draw some random effects for the new individual, and predict conditional on those. In terms of implementation, the only suggestion I'd have would be to fork the repo and try to implement it on your own. Sorry! And I'm not sure how easy or realistic that is... e.g. I think you'd have to look at this code and see if you need to modify to draw new random effects conditional only on the longitudinal data and not anything to do with the survival submodel. It might actually be that it doesn't require conditioning on the survival endpoint itself, in which case it might not be too hard to modify. But sorry my head has been too long out of those details to really provide much useful context without diving back into the code...

frbrz commented 1 year ago

Hi Sam,

Thanks a lot for the very detailed reply. And no need to apologize, I think all packages I have seen (JMBayes, JoineREML) only focus on the joint model case, so I must be the one making weird requests ;)

Thanks also for the lead on where to look in the codes. Unfortunately, I do not have much time atm... but if I ever have the time to try what you suggest, I will update this post.