% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/negbin_helpers.R
\name{score_negbin}
\alias{score_negbin}
\title{Compute Negative Binomial Score Vector}
\usage{
score_negbin(X, y, mu, theta, weights = 1)
}
\arguments{
\item{X}{Design matrix (N x p).}

\item{y}{Response vector.}

\item{mu}{Mean vector \eqn{\exp(\mathbf{X}\boldsymbol{\beta})}.}

\item{theta}{Shape parameter.}

\item{weights}{Observation weights (default 1).}
}
\value{
Numeric column vector of length p (gradient).
}
\description{
Gradient of the NB2 log-likelihood with respect to
\eqn{\boldsymbol{\beta}} under the log link.
}
\details{
Under log link, \eqn{d\mu_i/d\eta_i = \mu_i}, so the score is
\deqn{\mathbf{u} = \mathbf{X}^{\top}\mathbf{w}_{\mathrm{obs}}
  \odot \frac{(y_i - \mu_i)\theta}{\theta + \mu_i}}
where the per-observation contribution
\eqn{(y_i - \mu_i)\theta/(\theta + \mu_i)} is the derivative of the
log-likelihood with respect to \eqn{\eta_i}.
}
\keyword{internal}
