drizopoulos / JMbayes2

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

Is abs(slope(...)) accepable? #56

Closed BangyaoZhao closed 1 year ago

BangyaoZhao commented 1 year ago

Thank you for this great package. I want to specify the functional_forms in the jm function as something like ~value(variable) + abs(slope(variable)). The purpose is to model the absolute value of the slope (so negative slopes and positive slopes are treated the same). Currently, the code raises no error and no warning if I do that. I just want to make sure if this is the correct way to do it.

drizopoulos commented 1 year ago

No, this will not work correctly. You will need to use the development version from GitHub and the vabs() function, e.g.,

lmeFit <- lme(log(serBilir) ~ year * sex, data = pbc2, random = ~ year | id)
CoxFit <- coxph(Surv(years, status2) ~ sex, data = pbc2.id)
jointFit <- jm(CoxFit, lmeFit, time_var = "year", 
               functional_forms = ~ value(log(serBilir)) + vabs(slope(log(serBilir))))
summary(jointFit)