Reputation: 509
I’m working with a dataset in R and trying to calculate the cumulative incidence for each case ID in the presence of competing risks. My dataset looks like this:
data <- data.frame(
case_id = 1:8,
exposure_time = c(5, 6, 7, 4, 3, 10, 11, 2),
event = c(1, 1, 2, 2, 1, 0, 0, 2),
weight = c(1.5, 2.0, 1.0, 0.5, 2.5, 1.2, 1.8, 1.3)
)
How can I correctly calculate the cumulative incidence for each case ID at the time of their event?
I have been using the cmprsk package to calculate the cumulative incidence functions, but I’m struggling to extract the cumulative incidence for each individual case ID. the expected outcome is something like this :
data$cuminc <- c(1.5, 2.0, 3.5, 2.8, 1.3, NA, NA, 6.0)
Any help or guidance would be greatly appreciated!
Upvotes: 0
Views: 50