Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.mediate.mer

Plotting Indirect, Direct, and Total Effects from Mediation Analysis of Multilevel Models


Description

Function to plot group-specific effects derived from causal mediation analysis of multilevel models.

Usage

## 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", ...)

Arguments

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'.

Author(s)

Kentaro Hirose, Princeton University, hirose@princeton.edu.

References

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.

See Also

Examples

# 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)

mediation

Causal Mediation Analysis

v4.5.0
GPL (>= 2)
Authors
Dustin Tingley <dtingley@gov.harvard.edu>, Teppei Yamamoto <teppei@mit.edu>, Kentaro Hirose <hirose@princeton.edu>, Luke Keele <ljk20@psu.edu>, Kosuke Imai <kimai@princeton.edu>, Minh Trinh <mdtrinh@mit.edu>, Weihuang Wong <wwong@mit.edu>
Initial release
2019-9-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.