library("survatr")
set.seed(2)
n_id <- 40L
K <- 5L
pp <- data.frame(
id = rep(seq_len(n_id), each = K),
t = rep(seq_len(K), times = n_id),
A = rep(rbinom(n_id, 1L, 0.5), each = K),
Y = rbinom(n_id * K, 1L, 0.1)
)
fit <- surv_fit(pp, "Y", "A", ~1, "id", "t", time_formula = ~ factor(t))
res <- contrast(
fit,
interventions = list(a1 = causatr::static(1), a0 = causatr::static(0)),
times = 1:5,
type = "risk_difference"
)
print(res)<survatr_result>
Type: risk_difference
Reference: a1
CI method: none
Time grid: [1, 5] (5 unique times)
Estimates: 10 rows
Contrasts: 5 rows
contrast time estimate se ci_lower ci_upper
<char> <int> <num> <num> <num> <num>
1: a0 vs a1 1 -0.07544723 NA NA NA
2: a0 vs a1 2 -0.14864586 NA NA NA
3: a0 vs a1 3 -0.19989649 NA NA NA
4: a0 vs a1 4 -0.21851107 NA NA NA
5: a0 vs a1 5 -0.21851107 NA NA NA