drizopoulos / JMbayes2

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

Possibly ID bug #2

Closed jpkrooney closed 3 years ago

jpkrooney commented 3 years ago

Hi. I think I found a small bug that occurs when the longitudinal grouping variable is named anything other than id. I made a reproducible example:

library(JMbayes)
library(JMbayes2)

#lets imagine the ID variable is names something else - i.e. "UID"
pbc2$UID <- pbc2$id
# remove originals
pbc2$id <- NULL

lmefit <- lme(fixed = log(serBilir) ~ year * sex, random =  ~ year | UID, data = pbc2)
coxfit <- coxph(Surv(years, status2) ~ drug + age, data = pbc2.id, x = TRUE, model = TRUE)

# JMBayes runs fine
#jm1 <- jointModelBayes(lmefit, coxfit, timeVar = "year")
# JMbayes2 gets confused
jm2 <- jm(coxfit, lmefit, time_var = "year")

Output:

Screenshot 2021-01-18 at 18 54 52
drizopoulos commented 3 years ago

As the error message suggests, you need to have the same id variable in both datasets used to fit the longitudinal and survival models. Hence, either you need to specify the id_var in jm() or you need to create the UID variable in pbc2.id.

Intentionally, this is a bit different than what was done in JMbayes.

jpkrooney commented 3 years ago

Ah ok thanks Dimitris - sorry my mistake