Compare two nested models using parametric bootstrap simulation of the likelihood ratio statistic. Supports models fitted via lm, lme4 (lmer/glmer), nlme (lme/gls), etc.

pb2_modcomp(
  fit1,
  fit0,
  nsim = 1000,
  sequential = FALSE,
  h = 20,
  engine = "serial",
  nworkers = 2,
  verbose = FALSE
)

Arguments

fit1

The larger (alternative) model.

fit0

The smaller (null) model.

nsim

Number of simulations. In fixed bootstrap: total number of simulations. In sequential bootstrap: maximum number of simulations allowed.

sequential

Logical; if TRUE, use sequential bootstrap sampling to reach target number of extreme hits.

h

Number of extreme hits to target in sequential sampling.

engine

Parallelisation engine: "serial", "parallel", or "future".

nworkers

Number of workers for parallel/future engine.

verbose

Logical; if TRUE, print progress messages.

Value

An object of class PBmodcomp, with print(), summary(), and plot() methods.

Details

The models should both be fitted by maximum likelihood (not REML). If REML was used, the function will automatically refit with REML = FALSE where possible.

Note

Best Practice: Always fit your models with the data= argument. This ensures all covariates used in the model formula are stored with the model object, enabling reliable simulation and refitting for bootstrap analysis, including on parallel workers. Without data=, refitting may fail in parallel contexts and reproducibility is compromised.