Two-stage Least Squares Estimation of the Average Causal Mediation Effects
Estimate quantities for causal mediation analysis using an instrumental variable estimator.
mediate_tsls(model.m, model.y, treat = "treat.name", conf.level = 0.95, robustSE = FALSE, cluster = NULL, boot = FALSE, sims = 1000, est_se = TRUE, ...)
model.m |
a fitted model object for mediator, of class |
model.y |
a fitted model object for outcome, of class |
treat |
a character string indicating the name of the treatment variable used in the models. |
conf.level |
level of the returned two-sided confidence intervals. Default is to return the 2.5 and 97.5 percentiles of the simulated quantities. |
robustSE |
a logical value. If 'TRUE', heteroskedasticity-consistent standard errors will be used. Default is 'FALSE'. |
cluster |
a variable indicating clusters for standard errors. Note that this should be a vector of cluster indicators itself, not a character string for the name of the variable. |
boot |
a logical value. if |
sims |
number of Monte Carlo draws for nonparametric bootstrap. |
est_se |
estimate standard errors. Primarily for internal use. Default is |
... |
other arguments passed to vcovCL in the sandwich package:
typically the |
mediate
returns an object of class "mediate
",
"mediate.tsls
", a list that contains the components listed below.
The function summary
can be used to obtain a table of the results.
d1 |
point estimate for average causal mediation effects. |
d1.ci |
confidence intervals for average causal mediation effect. The confidence level is set at the value specified in 'conf.level'. |
z0 |
point estimates for average direct effect. |
z0.ci |
confidence intervals for average direct effect. |
z0.p |
two-sided p-values for average causal direct effect. |
n0 |
the "proportions mediated", or the size of the average causal mediation effect relative to the total effect. |
n0.ci |
confidence intervals for the proportion mediated. |
n0.p |
two-sided p-values for proportion mediated. |
tau.coef |
point estimate for total effect. |
tau.ci |
confidence interval for total effect. |
tau.p |
two-sided p-values for total effect. |
boot |
logical, the |
treat |
a character string indicating the name of the 'treat' variable used. |
mediator |
a character string indicating the name of the 'mediator' variable used. |
INT |
a logical value indicating whether the model specification allows the effects to differ between the treatment and control conditions. |
conf.level |
the confidence level used. |
model.y |
the outcome model used. |
model.m |
the mediator model used. |
nobs |
number of observations in the model frame for 'model.m' and 'model.y'. May differ from the numbers in the original models input to 'mediate' if 'dropobs' was 'TRUE'. |
cluster |
the clusters used. |
Aroian, L. A. 1947. The probability function of the product of two normally distributed variables. *Annals of Mathematical Statistics,* 18, 265-271.
# Generate data. We use TSLS to address unobserved confounding (n). set.seed(123) sims <- 1000 dat <- data.frame(z = sample(0:1, sims, replace = TRUE), t = sample(0:1, sims, replace = TRUE)) dat$n <- rnorm(sims, mean = 1) dat$m <- rnorm(sims, mean = dat$z * 0.3 + dat$t * 0.2 + dat$n * 0.7, sd = 0.2) dat$y <- rnorm(sims, mean = 5 + dat$t + dat$m * (-3) + dat$n, sd = 1) model.m <- lm(m ~ t + z, data = dat) model.y <- lm(y ~ t + m, data = dat) cluster <- factor(sample(1:3, sims, replace = TRUE)) med <- mediate_tsls(model.m, model.y, cluster = cluster, treat = "t") summary(med)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.