I have the following data:
library(cobalt)
library(tidycmprsk)
library(ggsurvfit)
library(gtsummary)
set.seed(123)
lalonde <- cbind(lalonde,
event = sample(c(0, 1), size = 614, replace = TRUE, prob = c(0.84, 0.16)),
time = runif(614, min = 10, max = 365))
n <- ceiling(0.05 * nrow(lalonde))
selected_indices <- sample(1:nrow(lalonde), size = n)
lalonde[selected_indices, "event"] <- 2
lalonde$event <- factor(lalonde$event, levels = c(0, 1, 2),
labels = c("Censored", "Event1", "Event2"))
And I can derive absolute risks from the cumulative incidence function:
p <- cuminc(Surv(time, event) ~ treat, lalonde) %>%
tbl_cuminc(
times = c(180, 230),
label_header = "**{time}-day cuminc**")
which gives:
Characteristic 180-day cuminc 230-day cuminc
treat
0 8.1% (5.6%, 11%) 14% (11%, 19%)
1 9.1% (5.3%, 14%) 13% (8.2%, 20%)
How can I calculate the risk difference with confidence intervals for the specified time-points?