Description Usage Arguments Examples
This calculations an effect modifier's difference and corresponding standard error for the marginal cumulative incidence using objects obtained from the 'survtmle' package.
1 | surv_eff_mod(tmle_fit_1, tmle_fit_0)
|
tmle_fit_1 |
survtmle fit object for only patients with the effect modifier |
tmle_fit_0 |
survtmle fit object for only patients without the effect modifier |
dat_full |
The full data set containing all observations used to obtain each 'tmle_fit_1' and 'tmle_fit_0'. |
mod_var |
String containing column name of the effect modifying variable in 'dat_full'. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # Modified version of the survtmle vignette example
set.seed(1234)
n <- 1000
t_0 <- 6
trt <- rbinom(n, 1, 0.5)
eff <- rbinom(n, 1, 0.5)
adjustVars <- data.frame(W1 = round(runif(n)), W2 = round(runif(n, 0, 2)))
ftime <- round(1 + runif(n, 1, 4) - trt*eff + adjustVars$W1 + adjustVars$W2)
ftype <- round(runif(n, 0, 1))
dat <- data.frame(trt, eff, adjustVars, ftime, ftype)
# Run survtmle for all subjects without the effect modifier
dat_noeff <- dat[dat$eff == 0,]
trt <- dat_noeff$trt
adjustVars <- dat_noeff[c("W1", "W2")]
ftime <- dat_noeff$ftime
ftype <- dat_noeff$ftype
fit_noeff <- survtmle::survtmle(ftime = ftime, ftype = ftype,
trt = trt, adjustVars = adjustVars,
SL.trt = c("SL.glm", "SL.mean", "SL.step"),
SL.ftime = c("SL.glm", "SL.mean", "SL.step"),
SL.ctime = c("SL.glm", "SL.mean", "SL.step"),
method = "hazard", t0 = t_0)
# Run survtmle for all subjects with the effect modifier
dat_eff <- dat[dat$eff == 1,]
trt <- dat_eff$trt
adjustVars <- dat_eff[c("W1", "W2")]
ftime <- dat_eff$ftime
ftype <- dat_eff$ftype
fit_eff <- survtmle::survtmle(ftime = ftime, ftype = ftype,
trt = trt, adjustVars = adjustVars,
SL.trt = c("SL.glm", "SL.mean", "SL.step"),
SL.ftime = c("SL.glm", "SL.mean", "SL.step"),
SL.ctime = c("SL.glm", "SL.mean", "SL.step"),
method = "hazard", t0 = t_0)
# Using the full data set, specify the effect modification column name as a string and tmle fits as 3rd and 4th args
surv_eff_mod(tmle_fit_0 = fit_noeff, tmle_fit_1 = fit_eff)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.