drizopoulos / JMbayes2

Extended Joint Models for Longitudinal and Survival Data
https://drizopoulos.github.io/JMbayes2/
79 stars 23 forks source link

No MCMC samples for shared random effects? #44

Closed alexvolkmann closed 2 years ago

alexvolkmann commented 2 years ago

Is it possible to access the MCMC samples for the shared random effects of a joint model?

I'm assuming that the "b" element of the "mcmc" list of a "jm" object would be the place to find them. However, this is the only element of the list that does not have the right dimensions.

I'm interested in the fitted values of the model over the different MCMC samples. In a different issue it says to construct them using the design matrices and posterior means. However, the "Mean" element of the "statistics" component of a "jm" object does not equal the "b" element, so is it just one random sample?

Thanks!

# Standard Example
pbc2.id$status2 <- as.numeric(pbc2.id$status != 'alive')
CoxFit <- coxph(Surv(years, status2) ~ sex, data = pbc2.id)
fm1 <- lme(log(serBilir) ~ year * sex, data = pbc2, random = ~ year | id)
jointFit <- jm(CoxFit, list(fm1), time_var = "year",
                n_iter = 1200L, n_burnin = 200L, n_thin = 5L)
str(jointFit$mcmc$b)
drizopoulos commented 2 years ago

You need to use jm(..., save_random_effects = TRUE).