% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lrt_stationarity_inad.R
\name{test_stationarity_inad}
\alias{test_stationarity_inad}
\title{Likelihood ratio test for stationarity (INAD data)}
\usage{
test_stationarity_inad(
  y,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  blocks = NULL,
  constrain = "both",
  fit_unconstrained = NULL,
  verbose = FALSE,
  ...
)
}
\arguments{
\item{y}{Integer matrix with n_subjects rows and n_time columns.}

\item{order}{Model order (1 or 2).}

\item{thinning}{Thinning operator: "binom", "pois", or "nbinom".}

\item{innovation}{Innovation distribution: "pois", "bell", or "nbinom".}

\item{blocks}{Optional integer vector for block effects.}

\item{constrain}{Which parameters to constrain: "alpha", "theta", "both" for order 1;
"alpha1", "alpha2", "alpha", "theta", "all" for order 2.}

\item{fit_unconstrained}{Optional pre-computed unconstrained fit.}

\item{verbose}{Logical; if TRUE, print progress.}

\item{...}{Additional arguments.}
}
\value{
A list with class \code{"test_stationarity_inad"} containing:
\describe{
\item{method}{Inference method used (\code{"lrt"}).}
\item{fit_unconstrained}{Unconstrained INAD fit}
\item{fit_constrained}{Constrained INAD fit}
\item{constraint}{Human-readable null constraint description}
\item{statistic}{Test statistic value}
\item{lrt_stat}{Likelihood ratio test statistic}
\item{df}{Degrees of freedom}
\item{p_value}{Chi-square p-value}
\item{bic_unconstrained}{BIC of unconstrained model}
\item{bic_constrained}{BIC of constrained model}
\item{bic_selected}{Model selected by BIC}
\item{table}{Two-row model summary table}
}
}
\description{
Tests whether time-varying INAD parameters can be constrained to be constant
over time.
}
\details{
For order 1, the test can constrain \code{alpha}, \code{theta}, or both.
For order 2, it can constrain \code{alpha1}, \code{alpha2},
\code{alpha} (both), \code{theta}, or all supported time-varying
parameters.

Degrees of freedom are computed from the number of equality constraints
imposed under the null model relative to the unconstrained model.

Missing-data inputs are supported through the same \code{na_action} options
available in \code{\link{fit_inad}}. If \code{y} has missing values and
\code{na_action} is not supplied via \code{...}, this function defaults to
\code{na_action = "marginalize"}.
}
\examples{
set.seed(1)
y <- simulate_inad(
  n_subjects = 30,
  n_time = 5,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  alpha = 0.3,
  theta = 2
)
out <- test_stationarity_inad(
  y,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  constrain = "both",
  max_iter = 20
)
out$p_value
}
\references{
Li, C. and Zimmerman, D.L. (2026). Integer-valued antedependence models for
longitudinal count data. \emph{Biostatistics}.
}
\seealso{
\code{\link{run_stationarity_tests_inad}},
\code{\link{test_order_inad}}, \code{\link{fit_inad}}
}
