Learn R Programming

parameters (version 0.22.0)

bootstrap_model: Model bootstrapping

Description

Bootstrap a statistical model n times to return a data frame of estimates.

Usage

bootstrap_model(model, iterations = 1000, ...)

# S3 method for default bootstrap_model( model, iterations = 1000, type = "ordinary", parallel = c("no", "multicore", "snow"), n_cpus = 1, verbose = FALSE, ... )

# S3 method for merMod bootstrap_model( model, iterations = 1000, type = "parametric", parallel = c("no", "multicore", "snow"), n_cpus = 1, cluster = NULL, verbose = FALSE, ... )

Value

A data frame of bootstrapped estimates.

Arguments

model

Statistical model.

iterations

The number of draws to simulate/bootstrap.

...

Arguments passed to or from other methods.

type

Character string specifying the type of bootstrap. For mixed models of class merMod or glmmTMB, may be "parametric" (default) or "semiparametric" (see ?lme4::bootMer for details). For all other models, see argument sim in ?boot::boot (defaults to "ordinary").

parallel

The type of parallel operation to be used (if any).

n_cpus

Number of processes to be used in parallel operation.

verbose

Toggle warnings and messages.

cluster

Optional cluster when parallel = "snow". See ?lme4::bootMer for details.

Using with <strong>emmeans</strong>

The output can be passed directly to the various functions from the emmeans package, to obtain bootstrapped estimates, contrasts, simple slopes, etc. and their confidence intervals. These can then be passed to model_parameter() to obtain standard errors, p-values, etc. (see example).

Note that that p-values returned here are estimated under the assumption of translation equivariance: that shape of the sampling distribution is unaffected by the null being true or not. If this assumption does not hold, p-values can be biased, and it is suggested to use proper permutation tests to obtain non-parametric p-values.

Details

By default, boot::boot() is used to generate bootstraps from the model data, which are then used to update() the model, i.e. refit the model with the bootstrapped samples. For merMod objects (lme4) or models from glmmTMB, the lme4::bootMer() function is used to obtain bootstrapped samples. bootstrap_parameters() summarizes the bootstrapped model estimates.

See Also

bootstrap_parameters(), simulate_model(), simulate_parameters()

Examples

Run this code
if (FALSE) { # require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)
# \donttest{
model <- lm(mpg ~ wt + factor(cyl), data = mtcars)
b <- bootstrap_model(model)
print(head(b))

est <- emmeans::emmeans(b, consec ~ cyl)
print(model_parameters(est))
# }
}

Run the code above in your browser using DataLab