% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lrt_stationarity_cat.R
\name{test_stationarity_cat}
\alias{test_stationarity_cat}
\title{Likelihood ratio test for stationarity (categorical AD data)}
\usage{
test_stationarity_cat(
  y,
  order = 1,
  blocks = NULL,
  homogeneous = TRUE,
  n_categories = NULL,
  test = c("lrt", "score", "mlrt")
)
}
\arguments{
\item{y}{Integer matrix with n_subjects rows and n_time columns. Each entry
should be a category code from 1 to c.}

\item{order}{Antedependence order p. Default is 1.}

\item{blocks}{Optional integer vector of length n_subjects specifying group
membership.}

\item{homogeneous}{Logical. If TRUE (default), parameters are shared across
all groups.}

\item{n_categories}{Number of categories. If NULL, inferred from data.}

\item{test}{Type of test statistic. One of \code{"lrt"} (default),
\code{"score"}, or \code{"mlrt"}.}
}
\value{
A list of class \code{"cat_lrt"} containing:
\describe{
\item{method}{Inference method used: one of \code{"lrt"}, \code{"score"},
or \code{"mlrt"}.}
\item{lrt_stat}{Likelihood ratio test statistic}
\item{df}{Degrees of freedom}
\item{p_value}{P-value from chi-square distribution}
\item{fit_null}{Fitted stationary model (H0)}
\item{fit_alt}{Fitted non-stationary model (H1)}
\item{table}{Summary data frame}
}
}
\description{
Tests whether a categorical antedependence process satisfies stationarity
constraints in the AD parameterization.
}
\details{
The tested constraints are:
\enumerate{
\item The marginal distribution P(Yk) is constant for all k
\item The transition probabilities P(Yk | Y(k-p), ..., Y(k-1)) are
constant for all k > p
}

For AD order 1, these two constraints correspond to strict stationarity.
For AD order greater than 1, this function should be interpreted as testing
marginal-constancy plus time-invariant transitions; these constraints are
not, in general, sufficient for full strict stationarity.

This is stronger than time-invariance alone, which only requires condition 2.

This function currently supports complete data only.

The null hypothesis is tested against the general (non-stationary) AD(p)
model. The degrees of freedom are computed from the fitted parameter counts:
\deqn{df = n_{params}(H_1) - n_{params}(H_0)}
where \eqn{H_1} is the unconstrained non-stationary model and \eqn{H_0} is
the stationary model.
}
\examples{
\donttest{
# Simulate stationary AD(1) data
set.seed(123)
y <- simulate_cat(200, 6, order = 1, n_categories = 2)

# Test stationarity
test <- test_stationarity_cat(y, order = 1)
print(test)
}

}
\references{
Xie, Y. and Zimmerman, D. L. (2013). Antedependence models for nonstationary
categorical longitudinal data with ignorable missingness: likelihood-based
inference. \emph{Statistics in Medicine}, 32, 3274-3289.
}
\seealso{
\code{\link{test_timeinvariance_cat}}, \code{\link{test_order_cat}}
}
