Displays the results of Sobel and permutation/bootstrapping tests for simple mediation.
Usage
bspmed(x, y, m, data = NULL, cov = NULL, random = NULL, su = NA,
i = 1000, method = "permutation", alpha = 0.05, figure = TRUE, ...)
Arguments
- x
X variable: can be the name of a variable in the environment or data.
- y
Y variable: can be the name of a variable in the environment or data.
- m
Mediating variable: can be the name of a variable in the environment or data.
- data
data.frame
from which to pull variable, with the global environment as a fallback.- cov
A character vector of covariates to include in each path. Only accepted if
data
is also specified.- random
Variable to be included as a random intercept in an
lme
model:lme(y ~ x + m, random = ~ 1 | random)
- su
Subset applied across variables, e.g.,
su = x < 2 & m > 0
.- i
The number of iterations to be processed for bootstrapping. Default is
1000
.- method
Character specifying the test type. Anything starting with
b
will perform bootstrapping, otherwise will performs the non-iterative, permutation-of-residuals approach as described in Taylor and MacKinnon (2012; Eqs. 9 and 10).- alpha
The alpha level for the bootstrapping confidence interval. Default is
.05
(i.e., 2.5% and 97.5%).- figure
Logical; if
FALSE
, will not display a figure.- ...
Passes additional arguments to
medfig
iffigure
isTRUE
.
Details
Bootstrap confidence intervals indicate significance when they do not include zero (as they are confidence intervals of the effect). Permutation confidence intervals indicate significance when they do not include the indirect effect (as they are confidence intervals of the null effect).
References
Taylor, A. B., & MacKinnon, D. P. (2012). Four applications of permutation methods to testing a single-mediator model. Behavior research methods, 44, 806-844. doi: 10.3758/s13428-011-0181-x
See also
medfig
to make a figure from results.
Examples
# This displays the mediation of weight on the relationship
# between displacement and miles per gallon.
bspmed(disp, mpg, wt, scale(mtcars))
#> Effect of disp on mpg, by way of wt
#> Processed in 1.14 seconds
#>
#> Sobel
#> a b c c' indirect
#> b 0.888 -0.5440 -0.8476 -0.3645 -0.4831
#> p 0.000 0.0074 0.0000 0.0636 0.0055
#>
#> Permutation confidence intervals
#> 2.5% 97.5% all <|> -0.4831
#> CI -1.225169 -0.3872929 FALSE