% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gau_utils.R
\name{.rss_gau}
\alias{.rss_gau}
\title{Compute residual sum of squares from AD regression}
\usage{
.rss_gau(y, i, p, mu = NULL, include_intercept = TRUE)
}
\arguments{
\item{y}{Numeric matrix n_subjects by n_time.}

\item{i}{Time index (1-based).}

\item{p}{Number of predecessors to include in regression (can be 0).}

\item{mu}{Optional mean vector. If provided, data is centered by mu before regression.
If NULL, regression includes an intercept.}

\item{include_intercept}{Logical. If TRUE and mu is NULL, include intercept in regression.}
}
\value{
Residual sum of squares (scalar).
}
\description{
For time point i, regress Y_i on its p_i predecessors (Y_(i-1), ..., Y_(i-p_i))
and return the residual sum of squares.
}
\details{
When mu is provided, the regression is:
\code{(Y_i - mu_i) ~ (Y_(i-1) - mu_(i-1)) + ... + (Y_(i-p) - mu_(i-p))}
with no intercept.

When mu is NULL and include_intercept is TRUE:
\code{Y_i ~ 1 + Y_(i-1) + ... + Y_(i-p)}

For i = 1 or p = 0, the RSS is simply the sum of squared deviations from the mean
(or from mu_1 if provided).
}
\keyword{internal}
