setup_weight_plot: Set up a diagnostic plot of robust regression weights

View source: R/setup_weight_plot.R

setup_weight_plotR Documentation

Set up a diagnostic plot of robust regression weights

Description

Extract the relevant information for a diagnostic plot of the regression weights from robust mediation analysis. This plot allows to easily detect deviations from normality assumptions such as skewness or heavy tails.

Usage

setup_weight_plot(object, ...)

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

## S3 method for class 'reg_fit_mediation'
setup_weight_plot(object, outcome = NULL, npoints = 1000, ...)

Arguments

object

an object inheriting from class "fit_mediation" or "test_mediation" containing results from robust mediation analysis. Only mediation analysis objects fitted with the robust MM-estimator are supported.

...

additional arguments to be passed down.

outcome

a character vector specifying the outcome variables of the regressions to be included in the plot. This must be a subset of the hypothesized mediators and the dependent variable, or NULL (the default) to include all regressions of the mediation model.

npoints

the number of grid points used to evaluate the expected percentages. The default is to use 1000 grid points.

Details

This function is used internally by weight_plot(). It may also be useful for users who want to produce a similar plot, but who want more control over what information to display or how to display that information.

Value

An object of class "setup_weight_plot" with the following components:

data

a data frame containing the following information: the outcome variable of the regression (column Outcome; only if multiple regressions are to be included in the plot), whether the row corresponds to the negative or the positive tail of the residual distribution (column Tail), whether the row corresponds to the expected (under the normal distribution) or the empirical weights (column Weights), the weight thresholds (column Threshold), and the corresponding percentage of observations that have a weight below this threshold (column Percentage).

outcome

a character vector containing the outcome variables of the regressions to be included in the plot.

Author(s)

Andreas Alfons

References

Alfons, A., Ates, N.Y. and Groenen, P.J.F. (2022) Robust Mediation Analysis: The R Package robmed. Journal of Statistical Software, 103(13), 1–45. doi:10.18637/jss.v103.i13.

See Also

fit_mediation(), test_mediation(), weight_plot()

Examples

data("BSG2014")

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

# set up information for plot
setup <- setup_weight_plot(boot)
# create diagnostic plot of robust regression weights
weight_plot(setup) +
  scale_color_manual("", values = c("black", "#00BFC4")) +
  theme(legend.position = "top")


robmed documentation built on July 9, 2023, 6:29 p.m.