Plotting Indirect, Direct, and Total Effects from Mediation Analysis of Multilevel Models
Function to plot group-specific effects derived from causal mediation analysis of multilevel models.
## S3 method for class 'mediate.mer' plot(x, treatment = NULL, group.plots = FALSE, ask = prod(par("mfcol")) < nplots, xlim = NULL, ylim = NULL, xlab = "", ylab = "", main = NULL, lwd = 1.5, cex = 0.85, col = "black", ...)
x |
object of class 'mediate.mer' produced by 'mediate'. |
treatment |
a character string indicating the baseline treatment value of the estimated causal mediation effect and direct effect to plot. Can be either "control", "treated", or "both". If 'NULL' (default), both sets of estimates are plotted if and only if they differ. |
group.plots |
a logical value indicating whether group-specific effects should be plotted in addition to the population-averaged effects. |
ask |
a logical value. If 'TRUE', the user is asked for input before a new figure is plotted. Default is to ask only if the number of plots on current screen is fewer than necessary. |
xlim |
range of the horizontal axis. |
ylim |
range of the vertical axis. |
xlab |
label of the horizontal axis. |
ylab |
label of the vertical axis. |
main |
main title. |
lwd |
width of the horizontal bars for confidence intervals . |
cex |
size of the dots for point estimates. |
col |
color of the dots and horizontal bars for the estimates.. |
... |
additional parameters passed to 'plot'. |
Kentaro Hirose, Princeton University, hirose@princeton.edu.
Tingley, D., Yamamoto, T., Hirose, K., Imai, K. and Keele, L. (2014). "mediation: R package for Causal Mediation Analysis", Journal of Statistical Software, Vol. 59, No. 5, pp. 1-38.
# Examples with JOBS II Field Experiment # **For illustration purposes a small number of simulations are used** ## Not run: data(jobs) require(lme4) # educ: mediator group # occp: outcome group # Varying intercept for mediator model.m <- glmer(job_dich ~ treat + econ_hard + (1 | educ), family = binomial(link = "probit"), data = jobs) # Varying intercept and slope for outcome model.y <- glmer(work1 ~ treat + job_dich + econ_hard + (1 + treat | occp), family = binomial(link = "probit"), data = jobs) # Output based on mediator group multilevel <- mediate(model.m, model.y, treat = "treat", mediator = "job_dich", sims=50, group.out="educ") #plot(multilevel, group.plots=TRUE) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.