Skip to contents

Fits AD models of increasing orders and selects the best by BIC.

Usage

bic_order_cat(
  y,
  max_order = 2,
  blocks = NULL,
  homogeneous = TRUE,
  n_categories = NULL,
  criterion = "bic"
)

Arguments

y

Integer matrix of categorical data (n_subjects x n_time).

max_order

Maximum order to consider. Default is 2.

blocks

Optional block membership vector.

homogeneous

Whether to use homogeneous parameters across blocks.

n_categories

Number of categories (inferred if NULL).

criterion

Which criterion to use: "bic" (default) or "aic".

Value

A list containing:

table

Data frame with order, log_l, n_params, aic, bic

bic

Named numeric vector of BIC values by order

best_order

Order with lowest criterion value

criterion

Criterion used for order selection ("bic" or "aic")

fits

List of fitted models

Examples

if (FALSE) { # \dontrun{
y <- simulate_cat(100, 5, order = 1, n_categories = 2)
result <- bic_order_cat(y, max_order = 2)
print(result$table)
print(result$best_order)
} # }