% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/em_inad.R
\name{em_inad}
\alias{em_inad}
\title{EM algorithm for INAD model estimation}
\usage{
em_inad(
  y,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  blocks = NULL,
  max_iter = 200,
  tol = 1e-07,
  alpha_init = NULL,
  theta_init = NULL,
  tau_init = NULL,
  nb_inno_size = NULL,
  safeguard = TRUE,
  verbose = FALSE
)
}
\arguments{
\item{y}{Integer matrix with n_subjects rows and n_time columns.}

\item{order}{Model order (1 or 2). Order 0 does not require EM.}

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

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

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

\item{max_iter}{Maximum number of EM iterations.}

\item{tol}{Convergence tolerance for log-likelihood change.}

\item{alpha_init}{Optional initial values for alpha parameters.}

\item{theta_init}{Optional initial values for theta parameters.}

\item{tau_init}{Optional initial values for tau parameters.}

\item{nb_inno_size}{Size parameter for negative binomial innovation (if used).}

\item{safeguard}{Logical; if TRUE, use step-halving when likelihood decreases.}

\item{verbose}{Logical; if TRUE, print iteration progress.}
}
\value{
A list with class "inad_fit" containing estimated parameters.
}
\description{
Fits INAD models using the Expectation-Maximization algorithm.
This is an alternative to direct likelihood optimization.
}
\details{
For Gaussian and CAT EM entry points, see \code{\link{em_gau}} and
\code{\link{em_cat}}. For CAT specifically, \code{fit_cat()} supports
\code{na_action = "em"} for orders 0/1 and \code{na_action = "marginalize"}
for order 2 missing-data fits.
}
\examples{
set.seed(1)
y <- simulate_inad(
  n_subjects = 50,
  n_time = 5,
  order = 1,
  thinning = "binom",
  innovation = "pois",
  alpha = 0.25,
  theta = 2
)
fit <- em_inad(y, order = 1, thinning = "binom", innovation = "pois", max_iter = 20, tol = 1e-6)
fit$log_l
}
\seealso{
\code{\link{em_gau}}, \code{\link{em_cat}}, \code{\link{fit_inad}},
\code{\link{fit_cat}}
}
