% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hyreg.R
\name{xreg2_hyreg}
\alias{xreg2_hyreg}
\title{Hybrid Regression (xreg2 version)}
\usage{
xreg2_hyreg(
  formula,
  df,
  datatype = "method",
  init = numeric(),
  contdist = "normal",
  dichdist = "logistic",
  hetcont = NULL,
  hetdich = NULL,
  ul = Inf,
  ll = -Inf,
  lntheta = TRUE,
  lnsigma = TRUE,
  dichformula = NULL,
  ...
)
}
\arguments{
\item{formula}{A formula or list of formulas for the continuous component.
The dependent variable (left-hand side) must match a column in \code{df},
or use interval columns named \code{varname.lb} and \code{varname.ub}.}

\item{df}{A \code{data.frame} containing both continuous and dichotomous
observations. Must include the column specified by \code{datatype}.}

\item{datatype}{Character; name of the column that distinguishes continuous
(\code{TRUE}) from dichotomous (\code{FALSE}) observations. Default
\code{"method"}.}

\item{init}{Optional named numeric vector (or \code{xreg2} object) of
starting values.}

\item{contdist}{Character; distribution for the continuous component.
\code{"normal"} (default) or \code{"logistic"}.}

\item{dichdist}{Character; distribution for the dichotomous component.
\code{"logistic"} (default) or \code{"normal"}.}

\item{hetcont}{Optional formula for heteroscedastic standard deviations in
the continuous component. If \code{NULL} (default), uses
\code{sigma_est ~ SIGMA} (or \code{sigma_est ~ exp(SIGMA)} when
\code{lnsigma = TRUE}).}

\item{hetdich}{Optional formula for heteroscedastic standard deviations in
the dichotomous component. If \code{NULL} (default), uses
\code{theta_est ~ THETA} (or \code{theta_est ~ exp(THETA)} when
\code{lntheta = TRUE}).}

\item{ul}{Numeric; upper censoring bound. Default \code{Inf}.}

\item{ll}{Numeric; lower censoring bound. Default \code{-Inf}.}

\item{lntheta}{Logical; exponentiate theta prior to fitting (matches STATA
default). Default \code{TRUE}.}

\item{lnsigma}{Logical; exponentiate sigma prior to fitting (matches STATA
default). Default \code{TRUE}.}

\item{dichformula}{Optional formula for the dichotomous component. Defaults
to \code{formula}.}

\item{...}{Additional arguments forwarded to \code{\link{xreg2_fit}}.}
}
\value{
An object of class \code{"xreg2"}.
}
\description{
High-level wrapper around \code{\link{xreg2_fit}} replicating
  the interface of the STATA \code{hyreg} command and
  \code{xreg::hyreg()}. Simultaneously fits a censored continuous model
  (normal or logistic) and a dichotomous model (logistic or normal) to a
  single data frame that contains both observation types.
}
\details{
Hybrid regression wrapper for xreg2
}
\examples{
\donttest{
set.seed(1)
n   <- 300
df  <- data.frame(
  value  = c(rnorm(200, 0.6, 0.3), rep(NA, 100)),
  age    = rnorm(n),
  method = c(rep(TRUE, 200), rep(FALSE, 100))
)
df$value[df$method == FALSE] <- as.integer(df$age[df$method == FALSE] > 0)

fit <- xreg2_hyreg(
  formula  = value ~ INTERCEPT + age * AGE,
  df       = df,
  datatype = "method"
)
print(fit)
}

}
\seealso{
\code{\link{xreg2_fit}}, \code{\link{xreg2_control}}
}
