do_boot | R Documentation |
Generate bootstrap
estimates to be used by
cond_indirect_effects()
,
indirect_effect()
, and
cond_indirect()
,
do_boot(
fit,
R = 100,
seed = NULL,
parallel = TRUE,
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
make_cluster_args = list(),
progress = TRUE
)
fit |
It can be (a) a list of |
R |
The number of bootstrap samples. Default is 100. |
seed |
The seed for the
bootstrapping. Default is |
parallel |
Logical. Whether
parallel processing will be used.
Default is |
ncores |
Integer. The number of
CPU cores to use when |
make_cluster_args |
A named list
of additional arguments to be passed
to |
progress |
Logical. Display
progress or not. Default is |
It does nonparametric
bootstrapping to generate bootstrap
estimates of the parameter estimates
in a model fitted either by
lavaan::sem()
or by a sequence of
calls to lm()
. The stored estimates
can then be used by
cond_indirect_effects()
,
indirect_effect()
, and
cond_indirect()
to form
bootstrapping confidence intervals.
This approach removes the need to
repeat bootstrapping in each call to
cond_indirect_effects()
,
indirect_effect()
, and
cond_indirect()
. It also ensures
that the same set of bootstrap
samples is used in all subsequent
analysis.
It determines the type of the fit
object automatically and then calls
lm2boot_out()
, fit2boot_out()
, or
fit2boot_out_do_boot()
.
Since Version 0.1.14.2, support for
multigroup models has been added for models
fitted by lavaan
. The implementation
of bootstrapping is identical to
that used by lavaan
, with resampling
done within each group.
A boot_out
-class object
that can be used for the boot_out
argument of
cond_indirect_effects()
,
indirect_effect()
, and
cond_indirect()
for forming
bootstrap confidence intervals. The
object is a list with the number of
elements equal to the number of
bootstrap samples. Each element is a
list of the parameter estimates and
sample variances and covariances of
the variables in each bootstrap
sample.
lm2boot_out()
,
fit2boot_out()
, and
fit2boot_out_do_boot()
, which
implements the bootstrapping.
data(data_med_mod_ab1)
dat <- data_med_mod_ab1
lm_m <- lm(m ~ x*w + c1 + c2, dat)
lm_y <- lm(y ~ m*w + x + c1 + c2, dat)
lm_out <- lm2list(lm_m, lm_y)
# In real research, R should be 2000 or even 5000
# In real research, no need to set parallel and progress to FALSE
# Parallel processing is enabled by default and
# progress is displayed by default.
lm_boot_out <- do_boot(lm_out, R = 50, seed = 1234,
parallel = FALSE,
progress = FALSE)
wlevels <- mod_levels(w = "w", fit = lm_out)
wlevels
out <- cond_indirect_effects(wlevels = wlevels,
x = "x",
y = "y",
m = "m",
fit = lm_out,
boot_ci = TRUE,
boot_out = lm_boot_out)
out
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.