(Robustly) estimate the effects in a mediation model.
fit_mediation(data, x, y, m, covariates = NULL,
method = c("regression", "covariance"), robust = TRUE,
median = FALSE, control, ...)
a data frame containing the variables.
a character string, an integer or a logical vector specifying the
column of data
containing the independent variable.
a character string, an integer or a logical vector specifying the
column of data
containing the dependent variable.
a character, integer or logical vector specifying the columns of
data
containing the hypothesized mediator variables.
optional; a character, integer or logical vector
specifying the columns of data
containing additional covariates to be
used as control variables.
a character string specifying the method of
estimation. Possible values are "regression"
(the default)
to estimate the effects via regressions, or "covariance"
to
estimate the effects via the covariance matrix. Note that the effects are
always estimated via regressions if more than one hypothesized mediator is
supplied in m
, or if control variables are specified via
covariates
.
a logical indicating whether to robustly estimate the effects
(defaults to TRUE
).
a logical indicating if the effects should be estimated via
median regression (defaults to FALSE
). This is ignored unless
method
is "regression"
and robust
is TRUE
.
a list of tuning parameters for the corresponding robust
method. For robust regression (method = "regression"
,
robust = TRUE
and median = FALSE
), a list of tuning
parameters for lmrob
as generated by
reg_control
. For Huberized covariance matrix estimation
(method = "covariance"
and robust = TRUE
), a list of tuning
parameters for cov_Huber
as generated by
cov_control
. No tuning parameters are necessary for median
regression (method = "regression"
, robust = TRUE
and
median = TRUE
).
additional arguments can be used to specify tuning parameters
directly instead of via control
.
An object inheriting from class "fit_mediation"
(class
"reg_fit_mediation"
if method
is "regression"
or
"cov_fit_mediation"
if method
is "covariance"
) with
the following components:
a numeric vector containing the point estimates of the effect of the independent variable on the proposed mediator variables.
a numeric vector containing the point estimates of the direct effect of the proposed mediator variables on the dependent variable.
numeric; the point estimate of the direct effect of the independent variable on the dependent variable.
numeric; the point estimate of the total effect of the independent variable on the dependent variable.
an object of class "lmrob"
or
"lm"
containing the estimation results from the
regression of the proposed mediator variable on the independent variable, or
a list of such objects in case of more than one hypothesized mediator
(only "reg_fit_mediation"
).
an object of class "lmrob"
or
"lm"
containing the estimation results from the
regression of the dependent variable on the proposed mediator and
independent variables (only "reg_fit_mediation"
).
an object of class "lm"
containing the
estimation results from the regression of the dependent variable on the
independent variable (only "reg_fit_mediation"
and if robust
is FALSE
).
an object of class "cov_Huber"
or
"cov_ML"
containing the covariance matrix estimates
(only "cov_fit_mediation"
).
character vectors specifying the respective variables used.
a data frame containing the independent, dependent and proposed mediator variables, as well as covariates.
a logical indicating whether the effects were estimated robustly.
a logical indicating whether the effects were estimated
via median regression (only "reg_fit_mediation"
).
a list of tuning parameters used (only if robust
is
TRUE
).
If method
is "regression"
, robust
is TRUE
and
median
is FALSE
(the defaults), the effects are estimated via
robust regressions with lmrob
.
If method
is "regression"
, robust
is TRUE
and
median
is TRUE
, the effects are estimated via median
regressions with rq
. Unlike the robust regressions
above, median regressions are not robust against outliers in the explanatory
variables.
If method
is "covariance"
and robust
is TRUE
,
the effects are estimated based on a Huber M-estimator of location and
scatter. Note that this covariance-based approach is less robust than the
approach based on robust regressions described above.
Alfons, A., Ates, N.Y. and Groenen, P.J.F. (2018) A robust bootstrap test for mediation analysis. ERIM Report Series in Management, Erasmus Research Institute of Management. URL https://hdl.handle.net/1765/109594.
Yuan, Y. and MacKinnon, D.P. (2014) Robust mediation analysis based on median regression. Psychological Methods, 19(1), 1--20.
Zu, J. and Yuan, K.-H. (2010) Local influence and robust procedures for mediation analysis. Multivariate Behavioral Research, 45(1), 1--44.
# NOT RUN {
data("BSG2014")
fit <- fit_mediation(BSG2014,
x = "ValueDiversity",
y = "TeamCommitment",
m = "TaskConflict")
test <- test_mediation(fit)
summary(test)
# }
Run the code above in your browser using DataLab