% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/negbin_helpers.R
\name{unconstrained_fit_negbin}
\alias{unconstrained_fit_negbin}
\title{Unconstrained NB Estimation for lgspline}
\usage{
unconstrained_fit_negbin(
  X,
  y,
  LambdaHalf,
  Lambda,
  keep_weighted_Lambda,
  family,
  tol = 1e-08,
  K,
  parallel,
  cl,
  chunk_size,
  num_chunks,
  rem_chunks,
  order_indices,
  weights
)
}
\arguments{
\item{X}{Design matrix (N_k x p) for partition k.}

\item{y}{Response counts for partition k.}

\item{LambdaHalf}{Square root of penalty matrix.}

\item{Lambda}{Penalty matrix.}

\item{keep_weighted_Lambda}{Logical; if TRUE, return hot-start estimates
from augmented Poisson regression without refinement.}

\item{family}{NB family object.}

\item{tol}{Convergence tolerance.}

\item{K}{Number of knots.}

\item{parallel}{Logical for parallel processing.}

\item{cl}{Cluster object.}

\item{chunk_size, }{num_chunks, rem_chunks Parallelism parameters.}

\item{order_indices}{Observation indices mapping partition to full data.}

\item{weights}{Observation weights.}
}
\value{
Numeric column vector of penalized coefficient estimates.
}
\description{
Estimates penalized NB2 coefficients for a single partition (or the
full model when K = 0) using a two-stage optimization: outer loop
profiles over \eqn{\theta} via Brent's method, inner loop estimates
\eqn{\boldsymbol{\beta}} via damped Newton-Raphson on the penalized
log-likelihood.
}
\details{
The penalized log-likelihood is
\deqn{\ell_p(\boldsymbol{\beta}, \theta) = \ell(\boldsymbol{\beta},
  \theta) - \tfrac{1}{2}\boldsymbol{\beta}^{\top}
  \boldsymbol{\Lambda}\boldsymbol{\beta}}

The outer loop optimizes \eqn{\theta} given the inner-loop-optimal
\eqn{\boldsymbol{\beta}(\theta)}. This mirrors the Weibull AFT
approach where scale (\eqn{\sigma}) is profiled out.

Initialization uses Poisson regression coefficients as a hot start
(equivalent to \eqn{\theta \to \infty}).
}
\keyword{internal}
