% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/betaBinomial.R
\name{gradient_log_likelihood}
\alias{gradient_log_likelihood}
\title{Analytic gradient of the negative log-likelihood (mode 1)}
\usage{
gradient_log_likelihood(params, X, Z, y, weights = NULL)
}
\arguments{
\item{params}{A numeric vector containing all model parameters. The first
n_beta elements are coefficients for the mean model, and the remaining
elements are coefficients for the log-standard deviation model.}

\item{X}{A matrix of predictors for the mean model.}

\item{Z}{A matrix of predictors for the log-standard deviation model.}

\item{y}{A numeric vector of response values.}

\item{weights}{A numeric vector of weights for each observation
(NULL = equal weights).}
}
\value{
Numeric vector: gradient of the negative log-likelihood with
  respect to \code{params}.
}
\description{
Computes the exact gradient of \code{\link{log_likelihood}} with respect
to all regression coefficients. With \eqn{r = (y - \mu)/\sigma}:
\deqn{\partial\ell/\partial\mu = r/\sigma, \qquad
      \partial\ell/\partial\log\sigma = r^2 - 1.}
Coefficient gradients follow via the chain rule through the design
matrices. Contributions of observations whose log(sigma) linear predictor
is clamped (see \code{log_likelihood}) are zeroed, which is the exact
subgradient of the clamped objective. Non-finite per-observation terms
(matching the penalty branch of the objective) are zeroed as well.
}
\keyword{internal}
