% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lrt_mean_gau.R
\name{test_two_sample_gau}
\alias{test_two_sample_gau}
\title{Two-sample test for equality of mean profiles under antedependence}
\usage{
test_two_sample_gau(y, blocks, p = 1L, order = NULL, use_modified = TRUE)
}
\arguments{
\item{y}{Numeric matrix with n_subjects rows and n_time columns.}

\item{blocks}{Integer vector of length n_subjects indicating group membership
(must contain exactly two unique values, typically 1 and 2).}

\item{p}{Antedependence order of the common covariance structure. This is the
same order parameter named \code{order} in \code{\link{fit_gau}}.}

\item{order}{Optional alias for \code{p}. Supply only one of \code{p} or
\code{order}.}

\item{use_modified}{Logical. If TRUE (default), use modified test statistic.}
}
\value{
A list with class \code{gau_mean_test} containing:
\describe{
\item{method}{Inference method used (\code{"lrt"}).}
\item{test_type}{"two-sample"}
\item{mu1_hat}{Estimated mean for group 1}
\item{mu2_hat}{Estimated mean for group 2}
\item{mu_pooled}{Pooled mean estimate under H0}
\item{statistic}{Test statistic value}
\item{statistic_modified}{Modified test statistic}
\item{df}{Degrees of freedom (n_time)}
\item{p_value}{P-value from chi-square distribution}
\item{p_value_modified}{P-value from modified test}
\item{order}{Antedependence order used}
}
}
\description{
Tests the null hypothesis that two groups have equal mean profiles
mu_1 = mu_2 against the alternative mu_1 != mu_2, assuming a common
AD(p) covariance structure. This implements Theorem 7.3 of
Zimmerman & Núñez-Antón (2009).
}
\details{
This test is also known as a "profile comparison" test. The likelihood
ratio test statistic (Theorem 7.3) compares the pooled RSS (under H0:
common mean) to the sum of within-group RSS (under H1: separate means):

\deqn{N \sum_{i=1}^{n} [\log RSS_i(\mu) - \log RSS_i(\mu_1, \mu_2)]}

where RSS_i(mu) uses a common mean and RSS_i(mu_1, mu_2) uses group-specific
means.
}
\examples{
\donttest{
# Simulate data from two groups with different means
n1 <- 30
n2 <- 35
y1 <- simulate_gau(n1, n_time = 6, order = 1, mu = rep(10, 6))
y2 <- simulate_gau(n2, n_time = 6, order = 1, mu = rep(12, 6))
y <- rbind(y1, y2)
blocks <- c(rep(1, n1), rep(2, n2))

# Test equality of profiles
test <- test_two_sample_gau(y, blocks, p = 1)
print(test)
}

}
\references{
Zimmerman, D.L. and Núñez-Antón, V. (2009). Antedependence Models for
Longitudinal Data. Chapman & Hall/CRC. Chapter 7.
}
