shanpengli / FastJM

Efficient algorithms and implementation of joint models with longitudinal and competing risks data applying pseudo-adaptive quadrature rules and customized linear scan approach
5 stars 3 forks source link

Wrong R type for mapped vector. #1

Open faithghlee opened 2 years ago

faithghlee commented 2 years ago

Hello Dr. Li,

I looked up the documentation prior to posting here. https://cran.r-project.org/web/packages/FastJM/FastJM.pdf

I noticed the package comes with ydata and cdata and I run it with no issue for the jmcs function.

I tried replicating it on another dataset (namely dataset available in JM package)

library(JM)
library(fastJM)

fitLME <- lme(sqrt(CD4) ~ obstime : drug, random = ~ obstime | patient, data = aids)
fitSURV <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE)
fitJM <- jointModel(fitLME, fitSURV, timeVar = "obstime", method = "piecewise-PH-GH")
summary(fitJM)

cdata$new_failure_type = ifelse(cdata$failure_type==2, 1, cdata$failure_type) # test on non competing risk 

fit <- jmcs(ydata = ydata, cdata = cdata, 
            long.formula = response ~ time + x1, 
            surv.formula = Surv(surv, new_failure_type) ~ x1 + x2, 
            random =  ~ time| ID)
aids.id$new_drug <- ifelse(aids.id$drug=="ddI", 1, 0) #avoid  getBayes error in FastJM 
aids$new_drug <- ifelse(aids$drug=="ddI", 1, 0)
fit <- jmcs(ydata = aids, cdata = aids.id, long.formula = sqrt(CD4)~obstime:new_drug, surv.formula = Surv(Time, death)~new_drug, random = ~obstime|patient )

It output an error as follows:

Error in getHazardSF(CumuH01, survtime, cmprsk, H01, CUH01, HAZ01) : 
  Wrong R type for mapped vector

I am not sure apart from what is mentioned in the documentation (long data for ydata arg and one id per line for cdata) if there is anything else specific I am missing. Would appreciate any input on this thank you!

shanpengli commented 2 years ago

Hi,

The current version of FastJM cannot recognize obstime:new_drug yet. You may want to manually create dummy variables and interaction variables for obstime:new_drug. However, I will work on this kind of calling and release a smarter version to recognize it in a month or so. Thanks!

Shanpeng

shanpengli commented 2 years ago

Also sqrt(CD4) is not recognized either.