Title: | Efficient Natural and Interventional Causal Mediation Analysis |
---|---|
Description: | Efficient estimators of interventional (in)direct effects in the presence of mediator-outcome confounding affected by exposure. The effects estimated allow for the impact of the exposure on the outcome through a direct path to be disentangled from that through mediators, even in the presence of intermediate confounders that complicate such a relationship. Currently supported are non-parametric efficient one-step and targeted minimum loss estimators based on the formulation of Díaz, Hejazi, Rudolph, and van der Laan (2020) <doi:10.1093/biomet/asaa085>. Support for efficient estimation of the natural (in)direct effects is also provided, appropriate for settings in which intermediate confounders are absent. The package also supports estimation of these effects when the mediators are measured using outcome-dependent two-phase sampling designs (e.g., case-cohort). |
Authors: | Nima Hejazi [aut, cre, cph] , Iván Díaz [aut] , Kara Rudolph [aut] , Philippe Boileau [ctb] , Mark van der Laan [ctb, ths] |
Maintainer: | Nima Hejazi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.2 |
Built: | 2024-10-28 02:52:19 UTC |
Source: | https://github.com/nhejazi/medoutcon |
Compute confidence intervals for objects of class medoutcon
, which
contain estimates produced by medoutcon
.
## S3 method for class 'medoutcon' confint(object, parm = seq_len(object$theta), level = 0.95, ...)
## S3 method for class 'medoutcon' confint(object, parm = seq_len(object$theta), level = 0.95, ...)
object |
An object of class |
parm |
A |
level |
A |
... |
Other arguments. Not currently used. |
Fit intermediate confounding mechanism with(out) conditioning on mediators
fit_moc_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names, type = c("q", "r") )
fit_moc_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names, type = c("q", "r") )
train_data |
A |
valid_data |
A holdout data set, with columns exactly matching those
appearing in the preceding argument |
contrast |
A |
learners |
|
m_names |
A |
w_names |
A |
type |
A |
Fit pseudo-outcome regression conditioning on mediator-outcome confounder
fit_nuisance_u( train_data, valid_data, learners, b_out, q_out, r_out, g_out, h_out, w_names )
fit_nuisance_u( train_data, valid_data, learners, b_out, q_out, r_out, g_out, h_out, w_names )
train_data |
A |
valid_data |
A holdout data set, with columns exactly matching those
appearing in the preceding argument |
learners |
|
b_out |
Output from the internal function for fitting the outcome
regression |
q_out |
Output from the internal function for fitting the mechanism of
the intermediate confounder while conditioning on mediators, i.e.,
|
r_out |
Output from the internal function for fitting the mechanism of
the intermediate confounder without conditioning on mediators, i.e.,
|
g_out |
Output from the internal function for fitting the treatment
mechanism without conditioning on mediators |
h_out |
Output from the internal function for fitting the treatment
mechanism conditioning on the mediators |
w_names |
A |
Fit pseudo-outcome regression conditioning on treatment and baseline
fit_nuisance_v( train_data, valid_data, contrast, learners, b_out, q_out, m_names, w_names )
fit_nuisance_v( train_data, valid_data, contrast, learners, b_out, q_out, m_names, w_names )
train_data |
A |
valid_data |
A holdout data set, with columns exactly matching those
appearing in the preceding argument |
contrast |
A |
learners |
|
b_out |
Output from the internal function for fitting the outcome
regression |
q_out |
Output from the internal function for fitting the mechanism of
the intermediate confounder while conditioning on the mediators, i.e.,
|
m_names |
A |
w_names |
A |
Fit outcome regression
fit_out_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names )
fit_out_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names )
train_data |
A |
valid_data |
A holdout data set, with columns exactly matching those
appearing in the preceding argument |
contrast |
A |
learners |
|
m_names |
A |
w_names |
A |
Fit propensity scores for treatment contrasts
fit_treat_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names, type = c("g", "h"), bounds = c(0.01, 0.99) )
fit_treat_mech( train_data, valid_data = NULL, contrast, learners, m_names, w_names, type = c("g", "h"), bounds = c(0.01, 0.99) )
train_data |
A |
valid_data |
A holdout data set, with columns exactly matching those
appearing in the preceding argument |
contrast |
A |
learners |
|
m_names |
A |
w_names |
A |
type |
A |
bounds |
A |
Efficient estimation of natural and interventional (in)direct effects
medoutcon( W, A, Z, M, Y, R = rep(1, length(Y)), obs_weights = rep(1, length(Y)), svy_weights = NULL, two_phase_weights = rep(1, length(Y)), effect = c("direct", "indirect", "pm"), contrast = NULL, g_learners = sl3::Lrnr_glm_fast$new(), h_learners = sl3::Lrnr_glm_fast$new(), b_learners = sl3::Lrnr_glm_fast$new(), q_learners = sl3::Lrnr_glm_fast$new(), r_learners = sl3::Lrnr_glm_fast$new(), u_learners = sl3::Lrnr_hal9001$new(), v_learners = sl3::Lrnr_hal9001$new(), d_learners = sl3::Lrnr_glm_fast$new(), estimator = c("tmle", "onestep"), estimator_args = list(cv_folds = 5L, max_iter = 5L, tiltmod_tol = 5), g_bounds = c(0.01, 0.99) )
medoutcon( W, A, Z, M, Y, R = rep(1, length(Y)), obs_weights = rep(1, length(Y)), svy_weights = NULL, two_phase_weights = rep(1, length(Y)), effect = c("direct", "indirect", "pm"), contrast = NULL, g_learners = sl3::Lrnr_glm_fast$new(), h_learners = sl3::Lrnr_glm_fast$new(), b_learners = sl3::Lrnr_glm_fast$new(), q_learners = sl3::Lrnr_glm_fast$new(), r_learners = sl3::Lrnr_glm_fast$new(), u_learners = sl3::Lrnr_hal9001$new(), v_learners = sl3::Lrnr_hal9001$new(), d_learners = sl3::Lrnr_glm_fast$new(), estimator = c("tmle", "onestep"), estimator_args = list(cv_folds = 5L, max_iter = 5L, tiltmod_tol = 5), g_bounds = c(0.01, 0.99) )
W |
A |
A |
A |
Z |
A |
M |
A |
Y |
A |
R |
A |
obs_weights |
A |
svy_weights |
A |
two_phase_weights |
A |
effect |
A |
contrast |
A |
g_learners |
A |
h_learners |
A |
b_learners |
A |
q_learners |
A |
r_learners |
A |
u_learners |
A |
v_learners |
A |
d_learners |
A |
estimator |
The desired estimator of the direct or indirect effect (or contrast-specific parameter) to be computed. Both an efficient one-step estimator using cross-fitting and a cross-validated targeted minimum loss estimator (TMLE) are available. The default is the TML estimator. |
estimator_args |
A |
g_bounds |
A |
# here, we show one-step and TML estimates of the interventional direct # effect; the indirect effect can be evaluated by a straightforward change # to the penultimate argument. the natural direct and indirect effects can # be evaluated by omitting the argument Z (inappropriate in this example). # create data: covariates W, exposure A, post-exposure-confounder Z, # mediator M, outcome Y n_obs <- 200 w_1 <- rbinom(n_obs, 1, prob = 0.6) w_2 <- rbinom(n_obs, 1, prob = 0.3) w <- as.data.frame(cbind(w_1, w_2)) a <- as.numeric(rbinom(n_obs, 1, plogis(rowSums(w) - 2))) z <- rbinom(n_obs, 1, plogis(rowMeans(-log(2) + w - a) + 0.2)) m_1 <- rbinom(n_obs, 1, plogis(rowSums(log(3) * w + a - z))) m_2 <- rbinom(n_obs, 1, plogis(rowSums(w - a - z))) m <- as.data.frame(cbind(m_1, m_2)) y <- rbinom(n_obs, 1, plogis(1 / (rowSums(w) - z + a + rowSums(m)))) # one-step estimate of the interventional direct effect os_de <- medoutcon( W = w, A = a, Z = z, M = m, Y = y, effect = "direct", estimator = "onestep" ) # TML estimate of the interventional direct effect # NOTE: improved variance estimate and de-biasing from targeting procedure tmle_de <- medoutcon( W = w, A = a, Z = z, M = m, Y = y, effect = "direct", estimator = "tmle" )
# here, we show one-step and TML estimates of the interventional direct # effect; the indirect effect can be evaluated by a straightforward change # to the penultimate argument. the natural direct and indirect effects can # be evaluated by omitting the argument Z (inappropriate in this example). # create data: covariates W, exposure A, post-exposure-confounder Z, # mediator M, outcome Y n_obs <- 200 w_1 <- rbinom(n_obs, 1, prob = 0.6) w_2 <- rbinom(n_obs, 1, prob = 0.3) w <- as.data.frame(cbind(w_1, w_2)) a <- as.numeric(rbinom(n_obs, 1, plogis(rowSums(w) - 2))) z <- rbinom(n_obs, 1, plogis(rowMeans(-log(2) + w - a) + 0.2)) m_1 <- rbinom(n_obs, 1, plogis(rowSums(log(3) * w + a - z))) m_2 <- rbinom(n_obs, 1, plogis(rowSums(w - a - z))) m <- as.data.frame(cbind(m_1, m_2)) y <- rbinom(n_obs, 1, plogis(1 / (rowSums(w) - z + a + rowSums(m)))) # one-step estimate of the interventional direct effect os_de <- medoutcon( W = w, A = a, Z = z, M = m, Y = y, effect = "direct", estimator = "onestep" ) # TML estimate of the interventional direct effect # NOTE: improved variance estimate and de-biasing from targeting procedure tmle_de <- medoutcon( W = w, A = a, Z = z, M = m, Y = y, effect = "direct", estimator = "tmle" )
The print
method for objects of class medoutcon
.
## S3 method for class 'medoutcon' print(x, ...)
## S3 method for class 'medoutcon' print(x, ...)
x |
An object of class |
... |
Other options (not currently used). |
Print a convenient summary for objects of S3
class medoutcon
.
## S3 method for class 'medoutcon' summary(object, ..., ci_level = 0.95)
## S3 method for class 'medoutcon' summary(object, ..., ci_level = 0.95)
object |
An object of class |
... |
Other arguments. Not currently used. |
ci_level |
A |