lm2boot_out {manymome}R Documentation

Bootstrap Estimates for lm Outputs

Description

Generate bootstrap estimates for models in a list of 'lm' outputs.

Usage

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
)

Arguments

outputs

A list of lm class objects, or the output of lm2list() (i.e., an lm_list-class object).

R

The number of bootstrap samples. Default is 100.

seed

The seed for the random resampling. Default is NULL.

progress

Logical. Display progress or not. Default is TRUE.

parallel

Logical. Whether parallel processing will be used. Default is NULL.

ncores

Integer. The number of CPU cores to use when parallel is TRUE. Default is the number of non-logical cores minus one (one minimum). Will raise an error if greater than the number of cores detected by parallel::detectCores(). If ncores is set, it will override make_cluster_args.

make_cluster_args

A named list of additional arguments to be passed to parallel::makeCluster(). For advanced users. See parallel::makeCluster() for details. Default is list().

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.

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.

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

See Also

do_boot(), the general purpose function that users should try first before using this function.

Examples


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


[Package manymome version 0.2.1 Index]