blrt: Bootstrap likelihood ratio test (non-regression only)

View source: R/blrt.R

blrtR Documentation

Bootstrap likelihood ratio test (non-regression only)

Description

Does the bootstrap likelihood ratio test. Provide two fitted models, the null model and the alt model fitted with a different number of clusters/latent classes. Bootstrap samples are generated using the null model. The null model and the alt model are refitted on the bootstrap samples to investigate the log likelihood ratio of the two models.

Usage

blrt(
  model_null,
  model_alt,
  n_bootstrap,
  n_thread = parallel::detectCores(),
  n_rep = 1,
  max_iter = 1000,
  tol = 1e-10
)

Arguments

model_null

Fitted poLCA object, the null model

model_alt

Fitted poLCA object, the alt model

n_bootstrap

Number of bootstrap samples

n_thread

Number of threads

n_rep

Number of initial values to try when fitting on the bootstrap samples

max_iter

Maximum number of iterations for EM algorithm

tol

Tolerance for difference in log likelihood, used for stopping condition

Details

Runs in parallel for each bootstrap sample, potentially high memory if the data is large

Value

List containing the following:

  • fitted_log_ratio: log likelihood ratio comparing the null and alt models

  • bootstrap_log_ratio: vector of length n_bootstrap, bootstrapped log likelihood ratio comparing the null and alt models

  • p_value: the proportion of bootstrap samples with log likelihood ratios greater than the fitted log likelihood ratio


poLCAParallel documentation built on Feb. 20, 2026, 1:09 a.m.