Description Usage Arguments Value References See Also Examples
rwrmed
is a function that implements the regression-with-residuals (RWR)
approach to causal mediation, allowing for post-treatment confounding of the mediator-outcome
relationship. Specifically, it fits user-specified mediator and outcome models with a set of
residualized post-treatment confounders. It returns an object of class rwrmed
, which can be
used for effect decomposition via the decomp
function.
1 2 |
treatment |
A character string indicating the name of the treatment variable, which can be either binary or continuous. |
pre_cov |
A character string vector indicating the names of the pretreatment covariates that are to be centered at their means. Thus factor-valued covariates should be pre-coded as dummy variables. |
zmodels |
A list of fitted |
y_form |
Formula for the outcome model. |
m_form |
Formula for the mediator model. |
m_family |
The family of the mediator model to be specified in |
weights |
An optional vector of weights to be used in fitting the outcome and mediator models. |
data |
A data frame containing the variables in the model. |
An object of class rwrmed
.
y_model |
The fitted outcome model. |
m_model |
The fitted mediator model. |
z_models |
Fitted |
var_names |
Names of the treatment variable, the mediator, the outcome, and the pretreatment and posttreatment covariates |
data |
The original data frame. |
data_ed |
The data frame with residualized pre- and post-treatment covariates |
call |
The matched call. |
Wodtke, Geoffrey T. and Xiang Zhou. 2019. "Effect Decomposition in the Presence of Treatment-induced Confounding: A Regression-with-Residuals Approach."
Zhou, Xiang and Geoffrey T. Wodtke. 2019. "A Regression-with-Residuals Method for Estimating Controlled Direct Effects." Political Analysis.
VanderWeele, Tyler J, Stijn Vansteelandt and James M Robins. 2014. "Effect Decomposition in the Presence of an Exposure-induced Mediator-outcome Confounder." Epidemiology 25:300-306.
VanderWeele, Tyler J. 2014. "A Unification of Mediation and Interaction: a Four-Way Decomposition." Epidemiology 25(5):749-761.
decomp
for effect decomposition based on a fitted rwrmed
object.
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 | ## an example with a continuous mediator ##
# treatment and pre-treatment covariates
treatment <- "tone_eth"
pre_cov <- c("ppage", "female", "hs", "sc", "ba", "ppincimp")
# outcome and mediator models
y_form <- immigr ~ ppage + female + hs + sc + ba + ppincimp +
tone_eth + emo + tone_eth * emo + p_harm
m_form <- emo ~ ppage + female + hs + sc + ba + ppincimp + tone_eth
# model for a post-treatment covariate
m1 <- lm(p_harm ~ ppage + female + hs + sc + ba + ppincimp + tone_eth,
data = immigration)
# effect decomposition using RWR
fit1 <- rwrmed(treatment = treatment, pre_cov = pre_cov, zmodels = list(m1),
y_form = y_form, m_form = m_form, data = immigration)
out1 <- decomp(fit1)
## an example with a binary mediator ##
# treatment and pre-treatment covariates
treatment <- "democ"
pre_cov <- c("ally", "trade", "h1", "i1", "p1", "e1", "r1", "male", "white", "age", "ed4")
# outcome and mediator models
y_form <- strike ~ ally + trade + h1 + i1 + p1 + e1 + r1 + male + white + age + ed4 + democ +
immoral + democ * immoral + threatc + cost + successc
m_form <- immoral ~ ally + trade + h1 + i1 + p1 + e1 + r1 + male + white + age + ed4 + democ
# models for post-treatment covariates
m1 <- lm(threatc ~ ally + trade + h1 + i1 + p1 + e1 + r1 + male + white + age + ed4 + democ,
data = peace)
m2 <- lm(cost ~ ally + trade + h1 + i1 + p1 + e1 + r1 + male + white + age + ed4 + democ,
data = peace)
m3 <- lm(successc ~ ally + trade + h1 + i1 + p1 + e1 + r1 + male + white + age + ed4 + democ,
data = peace)
# effect decomposition using RWR
fit2 <- rwrmed(treatment = treatment, pre_cov = pre_cov, zmodels = list(m1, m2, m3),
y_form = y_form, m_form = m_form, m_family = binomial("logit"), data = peace)
summary(fit2$m_model)
out2 <- decomp(fit2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.