plot_mediation: Plot (robust) mediation analysis results

Description Usage Arguments Value Author(s) See Also Examples

View source: R/plot.R

Description

Produce dot plots of selected coefficients from regression models computed in (robust) mediation analysis, or density plots of the indirect effect.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
plot_mediation(object, ...)

## S3 method for class 'boot_test_mediation'
plot_mediation(object, method = c("dot",
  "density"), parm = NULL, ...)

## S3 method for class 'sobel_test_mediation'
plot_mediation(object, data,
  method = c("dot", "density"), parm = c("c", "ab"), level = 0.95,
  ...)

## S3 method for class 'list'
plot_mediation(object, data, method = c("dot", "density"),
  parm = NULL, level = 0.95, ...)

## Default S3 method:
plot_mediation(object, mapping = attr(object,
  "mapping"), facets = attr(object, "facets"), ...)

## S3 method for class 'test_mediation'
autoplot(object, ...)

## S3 method for class 'test_mediation'
plot(x, ...)

Arguments

object, x

an object inheriting from class "test_mediation" containing results from (robust) mediation analysis. For plot_mediation, a list of such objects may be supplied as well.

...

additional arguments to be passed to and from methods.

method

a character string specifying which plot to produce. Possible values are "dot" for a dot plot of selected coefficients, or "density" for a density plot of the indirect effect(s).

parm

a character string specifying the coefficients to be included in a dot plot. The default is to include the direct and the indirect effect(s).

data

an optional numeric vector containing the x-values at which to evaluate the assumed normal density from Sobel's test (only used in case of a density plot). The default is to take 100 equally spaced points between the estimated indirect effect +/- three times the standard error according to Sobel's formula.

level

numeric; the confidence level of the confidence intervals from Sobel's test to be included in a dot plot. The default is to include 95% confidence intervals.

mapping

an aesthetic mapping to override the default behavior (see aes or aes_).

facets

a faceting formula to override the default behavior (only used in case of a dot plot). If supplied, facet_wrap or facet_grid is called depending on whether the formula is one-sided or two-sided.

Value

An object of class "ggplot" (see ggplot).

Author(s)

Andreas Alfons

See Also

test_mediation, fortify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
data("BSG2014")

# run fast and robust bootstrap test
robust_boot <- test_mediation(BSG2014,
                              x = "ValueDiversity",
                              y = "TeamCommitment",
                              m = "TaskConflict",
                              robust = TRUE)

# create plots for robust bootstrap test
plot(robust_boot, method = "dot")
plot(robust_boot, method = "density")

# run standard bootstrap test
standard_boot <- test_mediation(BSG2014,
                                x = "ValueDiversity",
                                y = "TeamCommitment",
                                m = "TaskConflict",
                                robust = FALSE)

# compare robust and standard tests
tests <- list(Robust = robust_boot, Standard = standard_boot)
plot_mediation(tests, method = "dot")
plot_mediation(tests, method = "density")

robmed documentation built on Nov. 5, 2018, 5:06 p.m.