weight_plot: Diagnostic plot of robust regression weights

View source: R/weight_plot.R

weight_plotR Documentation

Diagnostic plot of robust regression weights

Description

Produce 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

weight_plot(object, ...)

## Default S3 method:
weight_plot(object, outcome = NULL, npoints = 1000, ...)

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

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 and draw the expected percentages. The default is to use 1000 grid points.

Details

The horizontal axis contains different weight thresholds, and the vertical axis displays the percentage of observations that have a weight below this threshold. For comparison, a reference line is drawn for the expected percentages under normally distributed errors. Observations with negative and positive residuals are shown separately to make it possible to distinguish between symmetric and asymmetric deviations from normality.

If the plot reveals more downweighted observations than expected, but roughly the same amounts in both tails, the residual distribution is symmetric but with heavy tails. If the plot shows that observations in one tail are downweighted more heavily than those in the other tail, the residual distribution is skewed.

Value

An object inheriting from class "ggplot".

Note

The current implementation is a slight hack of ggplot2 and the grid graphics system in order to revert the horizontal axis only in the panels for observations with postive residuals. It is therefore not possible to change the horizontal axis with scale_x_continuous().

The implementation may change in the future if the required functionality becomes available in ggplot2.

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(), setup_weight_plot()

ci_plot(), density_plot(), ellipse_plot(), plot()

Examples

data("BSG2014")

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

# create diagnostic plot of robust regression weights
weight_plot(boot) +
  scale_color_manual("", values = c("black", "#00BFC4")) +
  theme(legend.position = "top")

# plot only the regression model for the hypothesized mediator
weight_plot(boot, outcome = "TaskConflict") +
  scale_color_manual("", values = c("black", "#00BFC4")) +
  theme(legend.position = "top")


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