% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bic_cat.R
\name{bic_order_cat}
\alias{bic_order_cat}
\title{BIC-based order selection for categorical AD models}
\usage{
bic_order_cat(
  y,
  max_order = 2,
  blocks = NULL,
  homogeneous = TRUE,
  n_categories = NULL,
  criterion = "bic"
)
}
\arguments{
\item{y}{Integer matrix of categorical data (n_subjects x n_time).}

\item{max_order}{Maximum order to consider. Default is 2.}

\item{blocks}{Optional block membership vector.}

\item{homogeneous}{Whether to use homogeneous parameters across blocks.}

\item{n_categories}{Number of categories (inferred if NULL).}

\item{criterion}{Which criterion to use: "bic" (default) or "aic".}
}
\value{
A list containing:
\item{table}{Data frame with order, log_l, n_params, aic, bic}
\item{bic}{Named numeric vector of BIC values by order}
\item{best_order}{Order with lowest criterion value}
\item{criterion}{Criterion used for order selection (\code{"bic"} or \code{"aic"})}
\item{fits}{List of fitted models}
}
\description{
Fits AD models of increasing orders and selects the best by BIC.
}
\examples{
\donttest{
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)
}

}
