| fit2boot_out {manymome} | R Documentation | 
Bootstrap Estimates for a
lavaan Output
Description
Generate bootstrap
estimates from the output of
lavaan::sem().
Usage
fit2boot_out(fit)
fit2boot_out_do_boot(
  fit,
  R = 100,
  seed = NULL,
  parallel = FALSE,
  ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
  make_cluster_args = list(),
  progress = TRUE,
  internal = list()
)
Arguments
| fit | The fit object. This function only supports a lavaan::lavaan object. | 
| R | The number of bootstrap samples. Default is 100. | 
| seed | The seed for the random
resampling. 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  | 
| internal | A list of arguments
to be used internally for debugging.
Default is  | 
Details
This function is for
advanced users. do_boot() is a
function users should try first
because do_boot() has a general
interface for input-specific
functions like this one.
If bootstrapping confidence intervals
was requested when calling
lavaan::sem() by setting se = "boot", fit2boot_out() can be used
to extract the stored bootstrap
estimates so that they can be reused
by indirect_effect(),
cond_indirect_effects() and related
functions to form bootstrapping
confidence intervals for effects such
as indirect effects and conditional
indirect effects.
If bootstrapping confidence was not
requested when fitting the model by
lavaan::sem(),
fit2boot_out_do_boot() can be used
to generate nonparametric bootstrap
estimates from the output of
lavaan::sem() and store them for
use by indirect_effect(),
cond_indirect_effects(), and
related functions.
This approach removes the need to
repeat bootstrapping in each call to
indirect_effect(),
cond_indirect_effects(), and
related functions. It also ensures
that the same set of bootstrap
samples is used in all subsequent
analyses.
Value
A boot_out-class object
that can be used for the boot_out
argument of indirect_effect(),
cond_indirect_effects(), and
related functions for forming
bootstrapping 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.
Functions
-  fit2boot_out(): Process stored bootstrap estimates for functions such ascond_indirect_effects().
-  fit2boot_out_do_boot(): Do bootstrapping and store information to be used bycond_indirect_effects()and related functions. Support parallel processing.
See Also
do_boot(), the general
purpose function that users should
try first before using this function.
Examples
library(lavaan)
data(data_med_mod_ab1)
dat <- data_med_mod_ab1
dat$"x:w" <- dat$x * dat$w
dat$"m:w" <- dat$m * dat$w
mod <-
"
m ~ x + w + x:w + c1 + c2
y ~ m + w + m:w + x + c1 + c2
"
# Bootstrapping not requested in calling lavaan::sem()
fit <- sem(model = mod, data = dat, fixed.x = FALSE,
           se = "none", baseline = FALSE)
fit_boot_out <- fit2boot_out_do_boot(fit = fit,
                                     R = 40,
                                     seed = 1234,
                                     progress = FALSE)
out <- cond_indirect_effects(wlevels = "w",
                             x = "x",
                             y = "y",
                             m = "m",
                             fit = fit,
                             boot_ci = TRUE,
                             boot_out = fit_boot_out)
out