library(adjustedCurves)
if (requireNamespace("geepack") & requireNamespace("prodlim")) {
set.seed(42)
# simulate some data as example
sim_dat <- sim_confounded_crisk(n=30, max_t=5)
sim_dat$group <- as.factor(sim_dat$group)
# estimate a treatment assignment model
glm_mod <- glm(group ~ x1 + x3 + x5 + x6, data=sim_dat, family="binomial")
# use it + pseudo values + geese model to calculate adjusted CIFs
adjcif <- adjustedcif(data=sim_dat,
variable="group",
ev_time="time",
event="event",
cause=1,
method="aiptw_pseudo",
outcome_vars=c("x1", "x2", "x3", "x4", "x5", "x6"),
treatment_model=glm_mod,
conf_int=FALSE,
force_bounds=TRUE,
iso_reg=TRUE)
# plot the curves
plot(adjcif)
}
Run the code above in your browser using DataLab