% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_gau.R
\name{fit_gau}
\alias{fit_gau}
\title{Fit Gaussian antedependence model by maximum likelihood}
\usage{
fit_gau(
  y,
  order = 1,
  blocks = NULL,
  na_action = c("fail", "complete", "em"),
  estimate_mu = TRUE,
  em_max_iter = 100,
  em_tol = 1e-06,
  em_verbose = FALSE,
  ...
)
}
\arguments{
\item{y}{Numeric matrix (n_subjects x n_time). May contain NA.}

\item{order}{Integer 0, 1, or 2.}

\item{blocks}{Optional vector of block membership (length n_subjects).}

\item{na_action}{One of "fail", "complete", or "em".}

\item{estimate_mu}{Logical, whether to estimate mu (default TRUE).}

\item{em_max_iter}{Maximum EM iterations (only used when na_action = "em").}

\item{em_tol}{EM convergence tolerance (only used when na_action = "em").}

\item{em_verbose}{Logical, print EM progress (only used when na_action = "em").}

\item{...}{Passed through to the EM fitter.}
}
\value{
A list with components including mu, phi, sigma, tau, log_l, n_obs, n_missing.
}
\description{
Fits an AD(0), AD(1), or AD(2) model for Gaussian longitudinal data
by maximum likelihood. Missing values can be handled by complete-case
deletion or by EM (see \code{\link{em_gau}} for an explicit EM wrapper).
}
\details{
For missing data with \code{na_action = "em"}, AD orders 0 and 1 are the
primary production path. AD order 2 is available, but the current EM
implementation uses simplified second-order updates and should be treated as
provisional for high-stakes inference.

For observed-data likelihood evaluation under MAR without fitting, use
\code{\link{logL_gau}} with \code{na_action = "marginalize"}. In contrast,
\code{fit_gau} handles missingness via complete-case fitting
(\code{na_action = "complete"}) or EM (\code{na_action = "em"}).
}
\examples{
set.seed(1)
y <- simulate_gau(n_subjects = 30, n_time = 5, order = 1, phi = 0.3)
fit <- fit_gau(y, order = 1)
fit$log_l

y_miss <- y
y_miss[1, 2] <- NA
fit_em <- fit_gau(y_miss, order = 1, na_action = "em", em_max_iter = 20)
fit_em$settings$na_action

}
\seealso{
\code{\link{em_gau}},
\code{\link{fit_cat}}, \code{\link{fit_inad}}
}
