pistacliffcho / icenReg_devel

Code for icenReg plus testData
4 stars 0 forks source link

Time-varying covariates #13

Open Erinaceida opened 2 years ago

Erinaceida commented 2 years ago

Thanks for the fantastic package!

Is there a way to fit a model with interval-censored outcome and time-varying covariates? Say my data looks like this:

`{r} id <- c(rep(1,3), rep(2,4)) screen_appointment <- c(12,20, 24, 50, 55, 70, 90) outcome <- c(0, 0, 1, rep(0, 4)) sex <- c(rep("F", 3), rep("M", 4)) weight <- c(75, 77, 60, 80, 80, 82, 82)

data.frame(id, screen_appointment, outcome, sex, weight) %>% group_by(id) %>% mutate(left = lag(screen_appointment, default = 0), right = screen_appointment) %>% select(-screen_appointment) `

Would that even be possible?

Thank you!

DrJerryTAO commented 3 months ago

Time-varying covariates is usually handled in the counting process format. Read manuals of the survival package for how to transform the data format into counting process. Particularly, "Using Time Dependent Covariates and Time Dependent Coeffcients in the Cox Model" https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf. Counting process format is distinct from interval censoring. The former requires an status indicator, taking values only 0 (event did not happen by the end of the time interval) or 1 (event happened at the end of the time interval), one subject taking multiple observations and rows. By contrast, the latter implicitly means that the event happened in each interval, one subject taking only one observation.

Therefore, I do not think icenReg can handle time-varying covariates because it does not allow counting process format. Your data seems to align with the counting process format, so the survival package should be enough.