% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lrt_homogeneity_inad.R
\name{test_homogeneity_inad}
\alias{test_homogeneity_inad}
\title{Likelihood ratio test for homogeneity across groups (INAD data)}
\usage{
test_homogeneity_inad(
  y,
  blocks,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  test = c("all", "mean", "dependence"),
  fit_pooled = NULL,
  fit_inadfe = NULL,
  fit_hetero = NULL,
  ...
)
}
\arguments{
\item{y}{Integer matrix with n_subjects rows and n_time columns.}

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

\item{order}{Antedependence order (0, 1, or 2).}

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

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

\item{test}{Type of homogeneity test:
\itemize{
\item \code{"all"}: Tests M1 (pooled) vs M3 (fully heterogeneous)
\item \code{"mean"}: Tests M1 (pooled) vs M2 (shared dependence, different means)
\item \code{"dependence"}: Tests M2 (INADFE) vs M3 (fully heterogeneous)
}}

\item{fit_pooled}{Optional pre-computed pooled fit (M1).}

\item{fit_inadfe}{Optional pre-computed INADFE fit (M2).}

\item{fit_hetero}{Optional pre-computed heterogeneous fit (M3).}

\item{...}{Additional arguments passed to \code{fit_inad}.}
}
\value{
A list with class \code{"test_homogeneity_inad"} containing:
\describe{
\item{method}{Inference method used (\code{"lrt"}).}
\item{statistic}{Test statistic value}
\item{lrt_stat}{Likelihood ratio test statistic}
\item{df}{Degrees of freedom}
\item{p_value}{P-value from chi-square distribution}
\item{test}{Type of test performed}
\item{fit_null}{Fitted model under H0}
\item{fit_alt}{Fitted model under H1}
\item{bic_null}{BIC under H0}
\item{bic_alt}{BIC under H1}
\item{bic_selected}{Which model BIC prefers}
\item{table}{Summary data frame}
}
}
\description{
Tests hypotheses about parameter equality across treatment or grouping
factors in integer-valued antedependence models. Implements the homogeneity
testing framework from Section 3.7 of Li & Zimmerman (2026).
}
\details{
The function supports three nested model comparisons as described in the paper:

\strong{M1 (Pooled)}: All parameters are common across groups. This corresponds
to fitting \code{fit_inad(y, blocks = NULL)}.

\strong{M2 (INADFE)}: The thinning parameters \eqn{\alpha} are shared across
groups, but innovation means differ via block effects \eqn{\tau}. This is the
standard INADFE model fitted via \code{fit_inad(y, blocks = blocks)}.

\strong{M3 (Fully Heterogeneous)}: Both \eqn{\alpha} and \eqn{\theta}
parameters can differ across groups. This is fitted by running separate
\code{fit_inad} calls for each group.

The three test types correspond to:
\itemize{
\item \code{"all"}: H0: M1 vs H1: M3 (complete homogeneity vs complete heterogeneity)
\item \code{"mean"}: H0: M1 vs H1: M2 (test for group differences in means only)
\item \code{"dependence"}: H0: M2 vs H1: M3 (test for group differences in dependence)
}

Degrees of freedom are computed as the difference in free parameters between
the null and alternative models.
}
\examples{
\donttest{
data("bolus_inad")
y <- bolus_inad$y
blocks <- bolus_inad$blocks

# Test for any group differences (M1 vs M3)
test_all <- test_homogeneity_inad(y, blocks, order = 1,
                                  thinning = "nbinom", innovation = "bell",
                                  test = "all")
print(test_all)

# Test only for mean differences (M1 vs M2)
test_mean <- test_homogeneity_inad(y, blocks, order = 1,
                                   thinning = "nbinom", innovation = "bell",
                                   test = "mean")
print(test_mean)

# Test for dependence differences given different means (M2 vs M3)
test_dep <- test_homogeneity_inad(y, blocks, order = 1,
                                  thinning = "nbinom", innovation = "bell",
                                  test = "dependence")
print(test_dep)
}

}
\references{
Li, C. and Zimmerman, D.L. (2026). Integer-valued antedependence models for
longitudinal count data. \emph{Biostatistics}. Section 3.7.
}
\seealso{
\code{\link{fit_inad}}, \code{\link{test_order_inad}},
\code{\link{test_stationarity_inad}}
}
