% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xreg2_fit.R
\name{xreg2_fit}
\alias{xreg2_fit}
\title{Fit xreg2 Model}
\usage{
xreg2_fit(
  controlList,
  dataList = NULL,
  start_values = numeric(),
  fixed_values = numeric(),
  latent_classes = 0,
  latent_class_parameters = character(),
  latent_id_colname = character(),
  return_type = "fit",
  print_sum = FALSE,
  method = "ucminf",
  hessian = TRUE,
  run_from = NULL,
  ...
)
}
\arguments{
\item{controlList}{An \code{xreg2ControlList} (produced by combining
\code{xreg2_control} objects with \code{c()}), an \code{xreg2_obj} (for
re-optimisation), or an \code{xreg2}/\code{xreg} fitted object (for
re-fitting).}

\item{dataList}{Named list of data frames, one per component. Names must
match those of \code{controlList}.}

\item{start_values}{Optional named numeric vector of starting values,
overriding those in \code{controlList}.}

\item{fixed_values}{Named numeric vector of parameter values held fixed.}

\item{latent_classes}{Integer; number of latent classes. \code{0} disables.}

\item{latent_class_parameters}{Character vector of parameter names that
vary by latent class.}

\item{latent_id_colname}{Character name of the grouping column for latent
classes.}

\item{return_type}{Character; \code{"fit"} (default), \code{"control"},
\code{"df"}, or \code{"predict"}.}

\item{print_sum}{Logical; print summary during optimisation. Default
\code{FALSE}.}

\item{method}{Character; optimisation method. Default \code{"ucminf"}.}

\item{hessian}{Logical; compute Hessian for standard errors. Default
\code{TRUE}.}

\item{run_from}{Internal; character string identifying the calling wrapper
(e.g. \code{"hyreg"}). Used to suppress certain warnings when called
from higher-level functions.}

\item{...}{Additional arguments passed to the optimiser.}
}
\value{
An object of class \code{"xreg2"} with fitted coefficients,
  standard errors, log-likelihoods, and counts.
}
\description{
Fits a flexible maximum-likelihood regression model supporting
  censored, interval, and hybrid data. Accepts a list of
  \code{\link{xreg2_control}} objects and a matching named list of
  data frames.
}
\details{
Fit a flexible maximum-likelihood regression model
}
\examples{
\donttest{
set.seed(1)
df   <- data.frame(y = rnorm(200, 2, 0.5), x = rnorm(200))
ctrl <- xreg2_control(
  formulas     = list(y ~ INTERCEPT + x * SLOPE),
  start_values = c(INTERCEPT = 0, SLOPE = 0),
  name         = "main"
)
fit  <- xreg2_fit(controlList = c(ctrl), dataList = list(main = df))
coef(fit)
}

}
\seealso{
\code{\link{xreg2_control}}, \code{\link{xreg2_optim}},
  \code{\link{predict.xreg2}}
}
