I'm trying to find a way to build a predictive model the development of a disease. However, some of our predictors are time-varying (aka time-dependent) -- for example, the appearance of other, age-related comorbidities.
We have a dataset with on the order of 1 million records, with about 15 million years of pt-time in follow-up
However, we have a fairly large number of potential predictors we could consider (on the order of 100 depending on how specifically we code comorbidities and concomitant medications) and the disease is quite rate (on the order of a couple of thousand events observed). Though this might suggest reasonable "events per variable" ratios, we still worry about over-fitting and would like to produce more parsimonious models using "the most important" predictors.
So, our current attempts involve penalized regression -- as in the lasso using the glmnet package in R -- using the counting process notation Surv(tstart, tstop, status) as a way to handle the time-varying covariates.
But, glmnet does not appear to be set up to handle interval censoring.
The glmnet package in R is able to address conventional cox regression, where all intervals start with an implicit time 0. However, when using the Surv(tstart, tstop, status) counting process notation, the software chokes in a way that suggests it was not designed to handle this case.
> l.fit <- glmnet(x, y, family="cox", alpha=1) Error: Cox model requires a matrix with columns 'time' (>0) and 'status' (binary) as a response; a 'Surv' object suffices
The documentation appears mute on this example, unless I'm missing something.
We would be grateful for suggestions on other ways to proceed, or perhaps alternative ways to specify the model such that glmnet could be used?
Thanks for any pointers or suggestions!
Here's the full example:
# Create Data jasa$subject <- 1:nrow(jasa) tdata <- with(jasa, data.frame(subject = subject, futime= pmax(.5, fu.date - accept.dt), txtime= ifelse(tx.date== fu.date, (tx.date -accept.dt) -.5, (tx.date - accept.dt)), fustat = fustat )) sdata <- tmerge(jasa, tdata, id=subject, death = event(futime, fustat), trt = tdc(txtime), options= list(idname="subject")) sdata$age <- sdata$age -48 sdata$year <- as.numeric(sdata$accept.dt - as.Date("1967-10-01"))/365.25 # Extended Cox formula; regular.fit <- coxph(Surv(tstart, tstop, death) ~ age*trt + surgery + year, data= sdata) summary(regular.fit) # create matrix x <- model.matrix(~age*trt + surgery + year, sdata) # create response y <- Surv(sdata$tstart, sdata$tstop, sdata$death) # fit lasso l.fit <- glmnet(x, y, family="cox", alpha=1) # Another attempt l.fit <- glmnet(x, Surv(sdata$tstart, sdata$tstop, sdata$death), family="cox", alpha=1)