Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Time-varying covariates #13

Open
Erinaceida opened this issue Sep 16, 2022 · 1 comment
Open

Time-varying covariates #13

Erinaceida opened this issue Sep 16, 2022 · 1 comment

Comments

@Erinaceida
Copy link

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
Copy link

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants