index_of_mome | R Documentation |
It computes the index of moderated mediation and the index of moderated moderated mediation proposed by Hayes (2015, 2018).
index_of_mome(
x,
y,
m = NULL,
w = NULL,
fit = NULL,
boot_ci = FALSE,
level = 0.95,
boot_out = NULL,
R = 100,
seed = NULL,
progress = TRUE,
mc_ci = FALSE,
mc_out = NULL,
ci_type = NULL,
ci_out = NULL,
boot_type = c("perc", "bc"),
...
)
index_of_momome(
x,
y,
m = NULL,
w = NULL,
z = NULL,
fit = NULL,
boot_ci = FALSE,
level = 0.95,
boot_out = NULL,
R = 100,
seed = NULL,
progress = TRUE,
mc_ci = FALSE,
mc_out = NULL,
ci_type = NULL,
ci_out = NULL,
boot_type = c("perc", "bc"),
...
)
x |
Character. The name of the predictor at the start of the path. |
y |
Character. The name of the outcome variable at the end of the path. |
m |
A vector of the variable
names of the mediator(s). The path
goes from the first mediator
successively to the last mediator. If
|
w |
Character. The name of the moderator. |
fit |
The fit object. Can be a
|
boot_ci |
Logical. Whether
bootstrap confidence interval will be
formed. Default is |
level |
The level of confidence for the bootstrap confidence interval. Default is .95. |
boot_out |
If |
R |
Integer. If |
seed |
If bootstrapping
or Monte Carlo simulation is
conducted, this is the seed for the
bootstrapping or simulation.
Default is |
progress |
Logical. Display
bootstrapping progress or not.
Default is |
mc_ci |
Logical. Whether
Monte Carlo confidence interval will be
formed. Default is |
mc_out |
If |
ci_type |
The type of
confidence intervals to be formed.
Can be either |
ci_out |
If |
boot_type |
If bootstrap
confidence interval is to be formed,
the type of bootstrap confidence
interval. The supported types
are |
... |
Arguments to be passed to
|
z |
Character. The name of the second moderator, for computing the index of moderated moderated mediation. |
The function
index_of_mome()
computes the index
of moderated mediation proposed by
Hayes (2015). It supports any path in
a model with one (and only one)
component path moderated. For
example, x->m1->m2->y
with x->m1
moderated by w
. It measures the
change in indirect effect when the
moderator increases by one unit.
The function index_of_momome()
computes the index of moderated
moderated mediation proposed by
Hayes (2018). It supports any path in
a model, with two component paths
moderated, each by one moderator. For
example, x->m1->m2->y
with x->m1
moderated by w
and m2->y
moderated by z
. It measures the
change in the index of moderated
mediation of one moderator when the
other moderator increases by one
unit.
It returns a
cond_indirect_diff
-class object.
This class has a print
method
(print.cond_indirect_diff()
), a
coef
method for extracting the
index (coef.cond_indirect_diff()
),
and a confint
method for extracting
the confidence interval if
available
(confint.cond_indirect_diff()
).
index_of_mome()
: Compute the
index of moderated mediation.
index_of_momome()
: Compute the
index of moderated moderated
mediation.
Hayes, A. F. (2015). An index and test of linear moderated mediation. Multivariate Behavioral Research, 50(1), 1-22. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00273171.2014.962683")}
Hayes, A. F. (2018). Partial, conditional, and moderated moderated mediation: Quantification, inference, and interpretation. Communication Monographs, 85(1), 4-40. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/03637751.2017.1352100")}
cond_indirect_effects()
library(lavaan)
dat <- modmed_x1m3w4y1
dat$xw1 <- dat$x * dat$w1
mod <-
"
m1 ~ a * x + f * w1 + d * xw1
y ~ b * m1 + cp * x
ind_mome := d * b
"
fit <- sem(mod, dat,
meanstructure = TRUE, fixed.x = FALSE,
se = "none", baseline = FALSE)
est <- parameterEstimates(fit)
# R should be at least 2000 or even 5000 in real research.
# parallel is set to TRUE by default.
# Therefore, in research, the argument parallel can be omitted.
out_mome <- index_of_mome(x = "x", y = "y", m = "m1", w = "w1",
fit = fit,
boot_ci = TRUE,
R = 42,
seed = 4314,
parallel = FALSE,
progress = FALSE)
out_mome
coef(out_mome)
# From lavaan
print(est[19, ], nd = 8)
confint(out_mome)
library(lavaan)
dat <- modmed_x1m3w4y1
dat$xw1 <- dat$x * dat$w1
dat$m1w4 <- dat$m1 * dat$w4
mod <-
"
m1 ~ a * x + f1 * w1 + d1 * xw1
y ~ b * m1 + f4 * w4 + d4 * m1w4 + cp * x
ind_momome := d1 * d4
"
fit <- sem(mod, dat,
meanstructure = TRUE, fixed.x = FALSE,
se = "none", baseline = FALSE)
est <- parameterEstimates(fit)
# See the example of index_of_mome on how to request
# bootstrap confidence interval.
out_momome <- index_of_momome(x = "x", y = "y", m = "m1",
w = "w1", z = "w4",
fit = fit)
out_momome
coef(out_momome)
print(est[32, ], nd = 8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.