Learn R Programming

robmed (version 0.6.0)

robmed-deprecated: Deprecated functions in package robmed

Description

These functions are provided for compatibility with older versions only, and may be defunct as soon as the next release.

Usage

# S3 method for boot_test_mediation
fortify(model, data, method = c("dot",
  "density"), parm = NULL, ...)

# S3 method for sobel_test_mediation fortify(model, data, method = c("dot", "density"), parm = NULL, level = 0.95, ...)

# S3 method for list fortify(model, data, ...)

plot_mediation(object, ...)

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

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

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

# S3 method for default plot_mediation(object, mapping = attr(object, "mapping"), facets = attr(object, "facets"), ...)

Arguments

model, object

an object inheriting from class "test_mediation" containing results from (robust) mediation analysis, or a list of such objects.

data

for the "boot_test_mediation" method, this is currently ignored. For the "sobel_test_mediation" method, this is 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 \(\pm\) three times the standard error according to Sobel's formula.

method

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

parm

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

additional arguments to be passed to and from methods.

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

fortify() returns a data frame containing the necessary data for the selected plot, as well as additional information stored in attributes.

plot_mediation() returns an object of class "ggplot".

Details

fortify() supplements the estimated coefficients with other useful information for informative visualization of the (robust) mediation analysis results. It is thereby possible to construct data frames for dot plots of selected effects, as well as density plots of the indirect effect. From version 0.6.0 onwards, it is recommended to use setup_ci_plot(), setup_density_plot(), or setup_ellipse_plot() instead.

plot_mediation() produces a dot plot of selected effects in the mediation model, or a density plot of the indirect effect. From version 0.6.0 onwards, it is recommended to use ci_plot(), density_plot(), or ellipse_plot() instead.

See Also

test_mediation(), ci_plot(), density_plot(), ellipse_plot()

Examples

Run this code
# NOT RUN {
data("BSG2014")

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

# create dot plot for robust bootstrap test
plot_mediation(robust_boot, method = "dot")
# equivalently
dot <- fortify(robust_boot, method = "dot")
plot_mediation(dot)

# create density plot for robust bootstrap test
plot_mediation(robust_boot, method = "density")
# equivalently
density <- fortify(robust_boot, method = "density")
plot_mediation(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(Standard = standard_boot, Robust = robust_boot)
plot_mediation(tests, method = "dot")
plot_mediation(tests, method = "density")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab