Residuals from stan_jm

I am running several models using rstanarm::stan_jm and would like to run various diagnostic models examining residuals from the longitudinal and event submodels to check the functional forms of the relations between predictor variables and residuals. Unlike residuals() for virtually every other model, residuals() for a stan_jm model returns:

Error in residuals.stanmvreg(jointmIAA) : Not currently implemented.

Is there a way to extract from the stanmvreg object the residuals from the two submodels, or alternatively to extract the submodels themselves in a way that would make it possible to extract the residuals?

Thanks to the rstanarm crew for developing these rstanarm functions! I know that I am pushing the limits of your models.

Larry Hunsicker

This is probably not the best forum. I, at least, can only offer a general answer, which is to carefully examine the model object. Here's an example from the function's help page; I'd include a reproducible example, called a reprex, but the output exceeds the allowed character count.

library(rstanarm)
# Univariate joint model, with association structure based on the 
# current value of the linear predictor
f1 <- stan_jm(formulaLong = logBili ~ year + (1 | id), 
              dataLong = pbcLong,
              formulaEvent = Surv(futimeYears, death) ~ sex + trt, 
              dataEvent = pbcSurv,
              time_var = "year",
              # this next line is only to keep the example small in size!
              chains = 1, cores = 1, seed = 12345, iter = 1000)
str(f1)

Yes. I should probably ask this question on the Stan forum. Thanks for your help.

Here is the thread on the Stan forum.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.