bootstrap_all: Parametric bootstrapping

View source: R/stats_helpers.R

bootstrap_allR Documentation

Parametric bootstrapping

Description

Parametric bootstrapping

Usage

bootstrap_all(
  nboot,
  mod,
  R2_type,
  all_comb,
  partition,
  data_mod,
  allow_neg_r2,
  parallel,
  expct,
  overdisp_name
)

Arguments

nboot

Number of parametric bootstrap iterations for confidence interval estimation (defaults to NULL, i.e. no bootstrapping). Larger numbers of bootstraps give a better asymptotic CI, but may be time-consuming. Bootstrapping can be switched on by setting nboot = 1000.

mod

merMod object, lme4 fit

R2_type

"marginal" or "conditional" R2. With "marginal", the variance explained by fixed effects is calculated. With "conditional", the variance explained by both fixed and random effects is calculated.

all_comb

list of predictor combinations

partition

TRUE or FALSE

data_mod

Data for model

allow_neg_r2

Calculating part R2 involves fitting two models, one with and one without the predictor of interest. In cases where the predictor has little association with the response, the resulting part R2 value can become negative. By default we set negative values to 0, but by setting this parameter to TRUE, R2 values can become negative.

parallel

If TRUE, computation uses future within furrr::map which allows parallelisation. However, it is necessary to specify a plan before running partR2(). To see which options you have, check ?future::plan and have a look at our vignette for details. When running RStudio, usually plan(multisession, workers = 4) is a good choice, when you want to use 4 cores. To detect how many cores you have, use parallel::detectCores(). If no plan is specified, partR2 will simply run sequentially.

expct

A string specifying the method for estimating the expectation in Poisson models with log link and in Binomial models with logit link (in all other cases the argument is ignored). The only valid terms are 'meanobs', 'latent', 'none' (and 'liability for binary and proportion data). With the default 'meanobs', the expectation is estimated as the mean of the observations in the sample. With 'latent', the expectation is estimated from estimates of the intercept and variances on the link scale. While this is a preferred solution, it is susceptible to the distribution of fixed effect covariates and gives appropriate results typically only when all covariances are centered to zero. With 'liability' estimates follow formulae as presented in Nakagawa & Schielzeth (2010). With 'none', R2 is calculated without distribution specific variance in the denominator.

overdisp_name

Name of overdispersion term

Value

Bootstrap samples for all statistics, plus associated warnings


partR2 documentation built on May 29, 2024, 2:29 a.m.