(Robustly) fit a mediation model

Share:

Description

(Robustly) estimate the effects in a mediation model.

Usage

1
2
fitMediation(x, y, m, covariates = NULL, data, method = c("covariance",
  "regression"), robust = TRUE, control, ...)

Arguments

x

either a numeric vector containing the independent variable, or (if data is supplied) a character string, an integer or a logical vector specifying the corresponding column of data.

y

either a numeric vector containing the dependent variable, or (if data is supplied) a character string, an integer or a logical vector specifying the corresponding column of data.

m

either a numeric vector containing the proposed mediator variable, or (if data is supplied) a character string, an integer or a logical vector specifying the corresponding column of data.

covariates

optional; either a numeric vector or data frame containing additional covariates to be used as control variables, or (if data is supplied) a character, integer or logical vector specifying the corresponding column of data.

data

an optional data.frame.

method

a character string specifying the method of estimation. Possible values are "covariance" (the default) to estimate the effects via the covariance matrix, or "regression" to estimate the effects via regressions. Note that the effects are always estimated via regressions if control variables are specified via covariates.

robust

a logical indicating whether to robustly estimate the effects (defaults to TRUE). This is currently ignored if method is "regression".

control

if robust is TRUE and method is "covariance", a list of tuning parameters for covHuber as generated by covControl.

...

additional arguments can be used to specify tuning parameters directly instead of via control.

Details

If method is "covariance" and robust is TRUE (the default), the effects are estimated based on a Huber M-estimator 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".

Value

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 "lm" containing the estimation results from the regression of the proposed mediator variable on the independent variable (only "regFitMediation").

fitYMX

an object of class "lm" containing the estimation results from the regression of the dependent variable on the proposed mediator and independent variables (only "regFitMediation").

fitYX

an object of class "lm" containing the estimation results from the regression of the dependent variable on the independent variable (only "regFitMediation").

cov

an object of class "covHuber" or "covML" containing the covariance matrix estimates (only "covFitMediation").

data

a data frame containing the independent, dependent and proposed mediator variables.

Author(s)

Andreas Alfons

References

Zu, J. and Yuan, K.-H. (2010) Local influence and robust procedures for mediation analysis. Multivariate Behavioral Research, 45(1), 1–44.

See Also

testMediation

covHuber, covML, lm

Examples

 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)