Learn R Programming

seqHMM (version 2.1.0)

bootstrap_coefs: Bootstrap Sampling of NHMM Coefficients

Description

The model estimation for each bootstrap sample uses the same method and tolerances as the original fit. If you want to change these, you can modify the elements of the input model such as model$estimation_results$method and model$controls before passing it to bootstrap_coefs().

Usage

bootstrap_coefs(model, ...)

# S3 method for nhmm bootstrap_coefs( model, nsim, type = c("nonparametric", "parametric"), append = FALSE, ... )

# S3 method for mnhmm bootstrap_coefs( model, nsim, type = c("nonparametric", "parametric"), append = FALSE, ... )

Value

The original model with additional element model$boot.

Arguments

model

An nhmm or mnhmm object.

...

Ignored.

nsim

number of bootstrap samples.

type

Either "nonparametric" (default) or "parametric", to define whether nonparametric or parametric bootstrap should be used. The former samples sequences with replacement, whereas the latter simulates new datasets based on the model.

append

If TRUE, in case the model already contains bootstrap samples, new samples are appended to model$boot. If FALSE (default), old samples are discarded.

Details

It is possible to parallelize the bootstrap runs using the future package, e.g., by calling future::plan(multisession, workers = 2) before bootstrap_coefs(). See future::plan() for details.

bootstrap_coefs() is compatible with progressr package, so you can use progressr::with_progress(bootstrap_coefs(fit)) to track the progress of bootstrapping.