Description Usage Arguments Value References See Also Examples
paths
estimates path-specific causal effects in the presence of K(≥q 1) causally
ordered mediators. It implements the pure imputation estimator and the imputation-based weighting
estimator (when a propensity score model is provided) as detailed in Zhou and Yamamoto (2020).
The user supplies the names of the treatment, outcome, mediator variables, K+1 fitted models
characterizing the conditional mean of the outcome given treatment, pretreatment confounders, and
varying sets of mediators, and a data frame containing all the variables. The function returns
K+1 path-specific causal effects that together constitute the total treatment effect.
When K=1, the path-specific causal effects are identical to the natural direct and indirect
effects in standard causal mediation analysis.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
a |
a character string indicating the name of the treatment variable. The treatment should be a binary variable taking either 0 or 1. |
y |
a character string indicating the name of the outcome variable. |
m |
a list of K character vectors indicating the names of K causally ordered mediators M_1,…, M_K. |
models |
a list of K+1 fitted model objects describing how the outcome depends on treatment, pretreatment confounders, and varying sets of mediators, where K is the number of mediators.
The fitted model objects can be of type |
ps_model |
an optional propensity score model for treatment. It can be of type |
data |
a data frame containing all variables. |
nboot |
number of bootstrap iterations for estimating confidence intervals. Default is 500. |
conf_level |
the confidence level of the returned two-sided confidence
intervals. Default is |
... |
additional arguments to be passed to |
x |
a fitted model object returned by the |
digits |
minimal number of significant digits printed. |
An object of class paths
, which is a list containing the
following elements
estimates of direct and path-specific effects via M_1, …, M_K based on the pure imputation estimator.
estimates of direct and path-specific effects via M_1, …, M_K based on the imputation-based weighting estimator.
a list of character strings indicating the names of the pretreatment confounders (X), treatment(A), mediators (M_1, …, M_K), and outcome (Y).
formulas for the outcome models.
classes of the outcome models.
model families of the outcome models.
a list containing arguments of the outcome models.
formula for the propensity score model.
class of the propensity score model.
model family of the propensity score model.
arguments of the propensity score model.
the original data.
number of bootstrap iterations.
confidence level for confidence intervals.
output matrix from the bootstrap iterations.
the matched call to the paths
function.
Zhou, Xiang and Teppei Yamamoto. 2020. "Tracing Causal Paths from Experimental and Observational Data".
summary.paths
, plot.paths
, sens
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | data(tatar)
m1 <- c("trust_g1", "victim_g1", "fear_g1")
m2 <- c("trust_g2", "victim_g2", "fear_g2")
m3 <- c("trust_g3", "victim_g3", "fear_g3")
mediators <- list(m1, m2, m3)
formula_m0 <- annex ~ kulak + prosoviet_pre + religiosity_pre + land_pre +
orchard_pre + animals_pre + carriage_pre + otherprop_pre + violence
formula_m1 <- update(formula_m0, ~ . + trust_g1 + victim_g1 + fear_g1)
formula_m2 <- update(formula_m1, ~ . + trust_g2 + victim_g2 + fear_g2)
formula_m3 <- update(formula_m2, ~ . + trust_g3 + victim_g3 + fear_g3)
formula_ps <- violence ~ kulak + prosoviet_pre + religiosity_pre +
land_pre + orchard_pre + animals_pre + carriage_pre + otherprop_pre
####################################################
# Causal Paths Analysis using GLM
####################################################
# outcome models
glm_m0 <- glm(formula_m0, family = binomial("logit"), data = tatar)
glm_m1 <- glm(formula_m1, family = binomial("logit"), data = tatar)
glm_m2 <- glm(formula_m2, family = binomial("logit"), data = tatar)
glm_m3 <- glm(formula_m3, family = binomial("logit"), data = tatar)
glm_ymodels <- list(glm_m0, glm_m1, glm_m2, glm_m3)
# propensity score model
glm_ps <- glm(formula_ps, family = binomial("logit"), data = tatar)
# causal paths analysis using glm
# note: For illustration purposes only a small number of bootstrap replicates are used
paths_glm <- paths(a = "violence", y = "annex", m = mediators,
glm_ymodels, ps_model = glm_ps, data = tatar, nboot = 3)
####################################################
# Causal Paths Analysis using GBM
####################################################
require(gbm)
# outcome models
gbm_m0 <- gbm(formula_m0, data = tatar, distribution = "bernoulli", interaction.depth = 3)
gbm_m1 <- gbm(formula_m1, data = tatar, distribution = "bernoulli", interaction.depth = 3)
gbm_m2 <- gbm(formula_m2, data = tatar, distribution = "bernoulli", interaction.depth = 3)
gbm_m3 <- gbm(formula_m3, data = tatar, distribution = "bernoulli", interaction.depth = 3)
gbm_ymodels <- list(gbm_m0, gbm_m1, gbm_m2, gbm_m3)
# propensity score model via gbm
gbm_ps <- gbm(formula_ps, data = tatar, distribution = "bernoulli", interaction.depth = 3)
# causal paths analysis using gbm
# note: For illustration purposes only a small number of bootstrap replicates are used
paths_gbm <- paths(a = "violence", y = "annex", m = mediators,
gbm_ymodels, ps_model = gbm_ps, data = tatar, nboot = 3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.