Description Usage Arguments Value Examples
Simple mediation analysis
1 2 3 |
data |
the data as a data frame |
dep |
a string naming the dependent variable |
mod |
a string naming the moderator variable |
pred |
a string naming the predictor variable |
estMethod |
|
bootstrap |
a number between 1 and 100000 (default: 1000) specifying the number of samples that need to been drawn in the bootstrap method |
test |
|
ci |
|
ciWidth |
a number between 50 and 99.9 (default: 95) specifying the
confidence interval width that is used as |
simpleSlopeEst |
|
simpleSlopePlot |
|
A results object containing:
results$mod | a table containing moderation estimates | ||||
results$simpleSlope$estimates | a table containing the simple slope estimates | ||||
results$simpleSlope$plot | an image | ||||
results$modelSyntax | the lavaan syntax used to fit the moderation model | ||||
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$mod$asDF
as.data.frame(results$mod)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | set.seed(1234)
X <- rnorm(10)
M <- rnorm(10)
X_M <- X*M
Y <- 0.7*X + 0.1*M + 4.2*X_M + rnorm(10)
dat <- data.frame(X=X, M=M, Y=Y)
mod(dat, dep = "Y", pred = "X", mod = "M")
#
# Moderation Estimates
# --------------------------------------------------
# Estimate SE Z p
# --------------------------------------------------
# X 0.951 0.0965 9.86 < .001
# M -0.471 0.0923 -5.10 < .001
# X:M 4.185 0.1009 41.50 < .001
# --------------------------------------------------
#
#
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.