delta_med {manymome} | R Documentation |
Delta_Med by Liu, Yuan, and Li (2023)
Description
It computes the
Delta_Med proposed by Liu, Yuan,
and Li (2023), an R^2
-like measure of
indirect effect.
Usage
delta_med(
x,
y,
m,
fit,
paths_to_remove = NULL,
boot_out = NULL,
level = 0.95,
progress = TRUE,
skip_check_single_x = FALSE,
skip_check_m_between_x_y = FALSE,
skip_check_x_to_y = FALSE,
skip_check_latent_variables = FALSE,
boot_type = c("perc", "bc")
)
Arguments
x |
The name of the |
y |
The name of the |
m |
A vector of the variable
names of the mediator(s). If more
than one mediators, they do not have
to be on the same path from |
fit |
The fit object. Must be a lavaan::lavaan object. |
paths_to_remove |
A character
vector of paths users want to
manually remove, specified in
|
boot_out |
The
output of |
level |
The level of confidence of the bootstrap confidence interval. Default is .95. |
progress |
Logical. Display
bootstrapping progress or not.
Default is |
skip_check_single_x |
Logical
Check whether the model has one and
only one x-variable. Default is |
skip_check_m_between_x_y |
Logical. Check whether all |
skip_check_x_to_y |
Logical.
Check whether there is a direct path
from |
skip_check_latent_variables |
Logical. Check whether the model
has any latent variables. Default
is |
boot_type |
If bootstrap
confidence interval is to be formed,
the type of bootstrap confidence
interval. The supported types
are |
Details
It computes Delta_Med, an
R^2
-like effect
size measure for the indirect effect
from one variable (the y
-variable)
to another variable (the x
-variable)
through one or more mediators
(m
, or m1
, m2
, etc. when
there are more than one mediator).
The Delta_Med of one or more
mediators was computed as the
difference between
two R^2
s:
-
R^2_1
, theR^2
wheny
is predicted byx
and all mediators. -
R^2_2
, theR^2
when the mediator(s) of interest is/are removed from the models, while the error term(s) of the mediator(s) is/are kept.
Delta_Med is given by
R^2_1 - R^2_2
.
Please refer to Liu et al. (2023) for the technical details.
The function can also form a nonparametric percentile bootstrap confidence of Delta_Med.
Value
A delta_med
class object.
It is a list-like object with these
major elements:
-
delta_med
: The Delta_Med. -
x
: The name of thex
-variable. -
y
: The name of they
-variable. -
m
: A character vector of the mediator(s) along a path. The path runs from the first element to the last element.
This class has a print
method,
a coef
method, and a confint
method. See print.delta_med()
,
coef.delta_med()
, and
confint.delta_med()
.
Implementation
The function identifies all the
path(s) pointing to the mediator(s)
of concern and fixes the path(s) to
zero, effectively removing the
mediator(s). However, the model is
not refitted, hence keeping the
estimates of all other parameters
unchanged.
It then uses lavaan::lav_model_set_parameters()
to update the parameters,
lavaan::lav_model_implied()
to
update the implied statistics, and
then calls lavaan::lavInspect()
to
retrieve the implied variance of the
predicted values of y
for computing
the R^2_2
. Subtracting this
R^2_2
from R^2_1
of
y
can then yield Delta_Med.
Model Requirements
For now, by default, it only computes Delta_Med for the types of models discussed in Liu et al. (2023):
Having one predictor (the
x
-variable).Having one or more mediators, the
m
-variables, with arbitrary way to mediate the effect ofx
on the outcome variable (y
-variable).Having one or more outcome variables. Although their models only have outcome variables, the computation of the Delta_Med is not affected by the presence of other outcome variables.
Having no control variables.
The mediator(s),
m
, and they
-variable are continuous.-
x
can be continuous or categorical. If categorical, it needs to be handle appropriately when fitting the model. -
x
has a direct path toy
. All the mediators listed in the argument
m
is present in at least one path fromx
toy.
None of the paths from
x
toy
are moderated.
It can be used for other kinds
of models but support for them is
disabled by default. To use
this function for
cases not discussed in
Liu et al. (2023), please disable
relevant requirements stated above
using the relevant
skip_check_*
arguments. An error
will be raised if the models failed
any of the checks not skipped by
users.
References
Liu, H., Yuan, K.-H., & Li, H. (2023). A systematic framework for defining R-squared measures in mediation analysis. Psychological Methods. Advance online publication. https://doi.org/10.1037/met0000571
See Also
print.delta_med()
,
coef.delta_med()
, and
confint.delta_med()
.
Examples
library(lavaan)
dat <- data_med
mod <-
"
m ~ x
y ~ m + x
"
fit <- sem(mod, dat)
dm <- delta_med(x = "x",
y = "y",
m = "m",
fit = fit)
dm
print(dm, full = TRUE)
# Call do_boot() to generate
# bootstrap estimates
# Use 2000 or even 5000 for R in real studies
# Set parallel to TRUE in real studies for faster bootstrapping
boot_out <- do_boot(fit,
R = 45,
seed = 879,
parallel = FALSE,
progress = FALSE)
# Remove 'progress = FALSE' in practice
dm_boot <- delta_med(x = "x",
y = "y",
m = "m",
fit = fit,
boot_out = boot_out,
progress = FALSE)
dm_boot
confint(dm_boot)