drizopoulos / JM

Joint Models for Longitudinal & Survival Data under Maximum Likelihood
34 stars 7 forks source link

Error in Xderiv %*% fixef(lmeObject)[derivForm$indFixed] : non-conformable arguments #23

Closed yugangjia closed 3 years ago

yugangjia commented 3 years ago

Hi, @drizopoulos, I am trying to use derivForm with splines and getting the following error: "Error in Xderiv %*% fixef(lmeObject)[derivForm$indFixed] : non-conformable arguments"

Can anyone show an example how to set the derivForm when you use splines in the linear mixed effect model? Here is my code

fitLME_poly <- lme(sofa_recent ~ ns(hr_day, 3)*ethnicity+U_sofa_adm+age10+male, random = list(stay_id = pdDiag(form = ~ ns(hr_day, 3))), data = mdat) fitCox_poly <- coxph(Surv(icu_day,died) ~ ethnicity+age10+male+U_sofa_adm,data=mdat.id,x=TRUE)

dForm <- list(fixed = ~ dns(hr_day, 3) + dns(hr_day, 3)*ethnicity, indFixed = c(2,3,4,11,12,13,14,15,16,17,18,19), random = ~ dns(hr_day, 3) , indRandom = c(2,3,4))

fitJM_pwph_poly <- jointModel(fitLME_poly,fitCox_poly,timeVar="hr_day", method="piecewise-PH-aGH", parameterization = "both", derivForm = dForm, control=list(verbose=TRUE,iter.EM=100)) Thanks

drizopoulos commented 3 years ago

There are example in my course notes, and sample script files in my website.