library("survatr")
# Small rectangular person-period dataset: 30 ids over 4 periods.
set.seed(1)
n_id <- 30L
K <- 4L
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))
# Contrast two static interventions; dispatches to contrast.survatr_fit().
contrast(
fit,
interventions = list(a1 = causatr::static(1), a0 = causatr::static(0)),
times = 1:4,
type = "risk_difference"
)