lm2boot_out | R Documentation |
lm
OutputsGenerate bootstrap estimates for models in a list of 'lm' outputs.
lm2boot_out(outputs, R = 100, seed = NULL, progress = TRUE)
lm2boot_out_parallel(
outputs,
R = 100,
seed = NULL,
parallel = FALSE,
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
make_cluster_args = list(),
progress = TRUE
)
outputs |
A list of |
R |
The number of bootstrap samples. Default is 100. |
seed |
The seed for the random
resampling. Default is |
progress |
Logical. Display
progress or not. 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 |
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.
It does nonparametric bootstrapping
to generate bootstrap estimates of
the regression coefficients in the
regression models of a list of lm()
outputs, or an lm_list
-class object
created by lm2list()
. The stored
estimates can be used by
indirect_effect()
,
cond_indirect_effects()
, and
related functions in forming
bootstrapping confidence intervals
for effects such as indirect effect
and conditional indirect effects.
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.
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.
lm2boot_out()
: Generate
bootstrap estimates using one process
(serial, without parallelization).
lm2boot_out_parallel()
: Generate
bootstrap estimates using parallel
processing.
do_boot()
, the general
purpose function that users should
try first before using this function.
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 progress to FALSE
# Progress is displayed by default.
lm_boot_out <- lm2boot_out(lm_out, R = 100, seed = 1234,
progress = FALSE)
out <- cond_indirect_effects(wlevels = "w",
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.