(Robustly) estimate the effects in a mediation model.
1 2 
x 
either a numeric vector containing the independent variable, or
(if 
y 
either a numeric vector containing the dependent variable, or
(if 
m 
either a numeric vector containing the proposed mediator variable,
or (if 
covariates 
optional; either a numeric vector or data frame
containing additional covariates to be used as control variables, or (if

data 
an optional 
method 
a character string specifying the method of
estimation. Possible values are 
robust 
a logical indicating whether to robustly estimate the effects
(defaults to 
control 
if 
... 
additional arguments can be used to specify tuning parameters
directly instead of via 
If method
is "covariance"
and robust
is TRUE
(the default), the effects are estimated based on a Huber Mestimator of
location and scatter.
A much more robust method based on robust regression will be available
soon. Currently, least squares regression is always performed if
method
is "regression"
.
An object inheriting from class "fitMediation"
(class
"regFitMediation"
if method
is "regression"
or
"covFitMediation"
if method
is "covariance"
) with
the following components:
a 
numeric; the point estimate of the effect of the independent variable on the proposed mediator variable. 
b 
numeric; the point estimate of the direct effect of the proposed mediator variable on the dependent variable. 
c 
numeric; the point estimate of the direct effect of the independent variable on the dependent variable. 
cPrime 
numeric; the point estimate of the total effect of the independent variable on the dependent variable. 
robust 
a logical indicating whether the effects were estimated robustly. 
fitMX 
an object of class 
fitYMX 
an object of class 
fitYX 
an object of class 
cov 
an object of class 
data 
a data frame containing the independent, dependent and proposed mediator variables. 
Andreas Alfons
Zu, J. and Yuan, K.H. (2010) Local influence and robust procedures for mediation analysis. Multivariate Behavioral Research, 45(1), 1–44.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  # control parameters
n < 250 # number of observations
a < b < c < 0.2 # true effects
t < 2 # number of observations to contaminate
# draw clean observations
set.seed(20160911)
x < rnorm(n)
m < a * x + rnorm(n)
y < b * m + c * x + rnorm(n)
# contaminate the first t observations
m[1:t] < m[1:t]  6
y[1:t] < y[1:t] + 6
# fit mediation model
fitMediation(x, y, m)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.