View source: R/cond_indirect_diff.R
cond_indirect_diff | R Documentation |
Compute the difference in conditional indirect effects between two sets of levels of the moderators.
cond_indirect_diff(output, from = NULL, to = NULL, level = 0.95)
output |
A
|
from |
A row number of |
to |
A row number of |
level |
The level of confidence for the confidence interval. Default is .95. |
Ths function takes the output of
cond_indirect_effects()
and
computes the difference in
conditional indirect effects between
any two rows, that is, between levels
of the moderator, or two sets of
levels of the moderators when the
path has more than one moderator.
The difference is meaningful when the difference between the two levels or sets of levels are meaningful. For example, if the two levels are the mean of the moderator and one standard deviation above mean of the moderator, then this difference is the change in indirect effect when the moderator increases by one standard deviation.
If the two levels are 0 and 1, then
this difference is the index of
moderated mediation as proposed by
Hayes (2015). (This index can also be
computed directly by
index_of_mome()
, designed
specifically for this purpose.)
The function can also compute the change in the standardized indirect effect between two levels of a moderator or two sets of levels of the moderators.
This function is intended to be a general purpose function that allows users to compute the difference between any two levels or sets of levels that are meaningful in a context.
This function itself does not set the
levels of comparison. The levels to
be compared need to be set when
calling cond_indirect_effects()
.
This function extracts required
information from the output of
cond_indirect_effects()
.
If bootstrap or Monte Carlo
estimates are available
in the input or bootstrap
or Monte Carlo confidence
intervals are requested in calling
cond_indirect_effects()
,
cond_indirect_diff()
will also form
the bootstrap confidence
interval for the difference in
conditional indirect effects
using the stored estimates.
If bootstrap confidence interval is to be formed and both effects used the same type of interval, then that type will be used. Otherwise, percentile confidence interval will be formed.
A cond_indirect_diff
-class
object. This class has a print
method
(print.cond_indirect_diff()
), a
coef
method
(coef.cond_indirect_diff()
), and a
confint
method
(confint.cond_indirect_diff()
).
cond_indirect_diff()
: Compute the difference in in
conditional indirect effect between
two rows in the output of
cond_indirect_effects()
.
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")}
index_of_mome()
for
computing the index of moderated
mediation, index_of_momome()
for
computing the index of moderated
moderated mediation,
cond_indirect_effects()
,
mod_levels()
, and
merge_mod_levels()
for preparing
the levels to be compared.
library(lavaan)
dat <- modmed_x1m3w4y1
dat$xw1 <- dat$x * dat$w1
mod <-
"
m1 ~ a * x + f * w1 + d * xw1
y ~ b * m1 + cp * x
"
fit <- sem(mod, dat,
meanstructure = TRUE, fixed.x = FALSE,
se = "none", baseline = FALSE)
est <- parameterEstimates(fit)
# Create levels of w1, the moderators
w1levels <- mod_levels("w1", fit = fit)
w1levels
# Conditional effects from x to y when w1 is equal to each of the levels
boot_out <- fit2boot_out_do_boot(fit, R = 40, seed = 4314, progress = FALSE)
out <- cond_indirect_effects(x = "x", y = "y", m = "m1",
wlevels = w1levels, fit = fit,
boot_ci = TRUE, boot_out = boot_out)
out
out_ind <- cond_indirect_diff(out, from = 2, to = 1)
out_ind
coef(out_ind)
confint(out_ind)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.