Description Usage Arguments Value Examples
View source: R/bootstrap_model.R
By default, this will compute bootstrap resamples
and then send them to bootstrap_ci
for calculation.
1 2 3 4 5 6 7 8 9 10 11 12 13 | bootstrap_model(
base_model,
base_data,
resamples = 9999,
return_coefs_instead = FALSE,
parallelism = c("none", "future", "parallel"),
resample_specific_blocks = NULL,
unique_resample_lim = NULL,
narrowness_avoid = TRUE,
num_cores = NULL,
future_packages = NULL,
suppress_sampling_message = !interactive()
)
|
base_model |
The pre-bootstrap model, i.e. the model output
from running a standard model call.
Examples:
|
base_data |
The data that was used in the call. You can leave this to be automatically read, but I highly recommend supplying it |
resamples |
How many resamples of your data do you want to do? 9,999 is a reasonable default (see Hesterberg 2015), but start very small to make sure it works on your data properly, and to get a rough timing estimate etc. |
return_coefs_instead |
Logical, default |
parallelism |
Type of parallelism (if any) to use to run the resamples. Options are:
|
resample_specific_blocks |
Character vector, default |
unique_resample_lim |
Should be same length as number of random effects
(or left |
narrowness_avoid |
Boolean, default |
num_cores |
How many cores to use.
Defaults to |
future_packages |
Packages to pass to created futures when
using |
suppress_sampling_message |
Logical, the default is
to suppress if not in an interactive session.
Do you want the function to message the console with the type of
bootstrapping? If block resampling over random effects, then it'll say
what effect it's sampling over; if case resampling -
in which case it'll say as much.
Set |
By default (with return_coefs_instead
being FALSE
),
returns the output from bootstrap_ci
;
for each set of covariates (usually just the one set,
the conditional model) we get a matrix of output: a row for each variable
(including the intercept),
estimate, CIs for boot and base, p-values.
If return_coefs_instead
is TRUE
, then will instead
return a list of length two:
a list containing the output for the base model
a list of length resamples
each a list of matrices of
estimates and standard errors for each model.
This output is useful for error checking, and if you want to run this function in certain distributed ways.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | x <- rnorm(20)
y <- rnorm(20) + x
xy_data = data.frame(x = x, y = y)
first_model <- lm(y ~ x, data = xy_data)
out_matrix <- bootstrap_model(first_model, base_data = xy_data, 20)
out_list <- bootstrap_model(first_model,
base_data = xy_data,
resamples = 20,
return_coefs_instead = TRUE)
data(test_data)
library(glmmTMB)
test_formula <- as.formula('y ~ x_var1 + x_var2 + x_var3 + (1|subj)')
test_model <- glmmTMB(test_formula, data = test_data, family = binomial)
output_matrix <- bootstrap_model(test_model, base_data = test_data, 199)
output_lists <- bootstrap_model(test_model,
base_data = test_data,
resamples = 199,
return_coefs_instead = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.