View source: R/test_indirect_effects.R
test_k_indirect_effects | R Documentation |
Test several indirect effects
for a power4test
object.
test_k_indirect_effects(
fit = fit,
x = NULL,
m = NULL,
y = NULL,
mc_ci = TRUE,
mc_out = NULL,
boot_ci = FALSE,
boot_out = NULL,
check_post_check = TRUE,
...,
omnibus = c("no", "all_sig", "at_least_one_sig", "at_least_k_sig"),
at_least_k = 1,
fit_name = "fit",
get_map_names = FALSE,
get_test_name = FALSE
)
fit |
The fit object, to be
passed to |
x |
The name of the |
m |
Must be a list of character
vectors. Each character vector stores the
name(s) of mediator(s) along a path.
The path
moves from the first mediator in the
vector to the last mediator in the
vector. If |
y |
The name of the |
mc_ci |
Logical. If |
mc_out |
The pre-generated
Monte Carlo estimates generated by
manymome::do_mc, stored in
a |
boot_ci |
Logical. If |
boot_out |
The pre-generated
bootstrap estimates generated by
manymome::do_boot, stored in
a |
check_post_check |
Logical. If
|
... |
Additional arguments to
be passed to |
omnibus |
If |
at_least_k |
The minimum number
of paths required to be significant
for the omnibus test to be considered
significant. Used when
|
fit_name |
The name of the
model fit object to be extracted.
Default is |
get_map_names |
Logical. Used
by |
get_test_name |
Logical. Used
by |
This function is to be used in
power4test()
for testing an
indirect effect, by setting it
to the test_fun
argument.
It uses manymome::many_indirect_effects()
to do the test. It can be used on
models fitted by lavaan::sem()
or fitted by a sequence of calls
to stats::lm()
, although only
nonparametric bootstrap confidence
interval is supported for models
fitted by regression using
stats::lm()
.
In its normal usage, it returns a data frame with the following columns:
est
: The estimated
indirect effect for each path.
cilo
and cihi
: The
lower and upper limits of the
confidence interval (95% by
default), respectively,
for each indirect effect
sig
: Whether a test by confidence
interval is significant (1
) or
not significant (0
).
test_label
: A column of labels
generated to label the indirect
effects.
If omnibus
is "all_sig"
or
"at_least_one"sig"
, then
the data frame has only one row,
and the columns "est"
, "cilo"
,
and "cihi"
are NA
. The column
sig
is determined by whether
all paths are significant ("all_sig"
)
or whether at least one path is
significant ("at_least_one_sig"
).
power4test()
# Specify the model
model_simple_med <-
"
m1 ~ x
m2 ~ x
y ~ m1 + m2 + x
"
# Specify the population values
model_simple_med_es <-
"
y ~ m1: s
m1 ~ x: m
y ~ m2: s
m2 ~ x: l
y ~ x: n
"
# Simulate the data
sim_only <- power4test(nrep = 5,
model = model_simple_med,
pop_es = model_simple_med_es,
n = 100,
R = 100,
do_the_test = FALSE,
iseed = 1234)
# Do the test in each replication
test_ind <- power4test(object = sim_only,
test_fun = test_k_indirect_effects,
test_args = list(x = "x",
y = "y",
mc_ci = TRUE))
print(test_ind,
test_long = TRUE)
# Set omnibus = "all_sig" to declare
# significant only if all paths are
# significant
test_ind_all_sig <- power4test(
object = sim_only,
test_fun = test_k_indirect_effects,
test_args = list(x = "x",
y = "y",
mc_ci = TRUE,
omnibus = "all_sig"))
print(test_ind_all_sig,
test_long = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.