gradient_log_likelihood: Analytic gradient of the negative log-likelihood (mode 1)

View source: R/betaBinomial.R

gradient_log_likelihoodR Documentation

Analytic gradient of the negative log-likelihood (mode 1)

Description

Computes the exact gradient of log_likelihood with respect to all regression coefficients. With r = (y - \mu)/\sigma:

\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 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.

Usage

gradient_log_likelihood(params, X, Z, y, weights = NULL)

Arguments

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.

X

A matrix of predictors for the mean model.

Z

A matrix of predictors for the log-standard deviation model.

y

A numeric vector of response values.

weights

A numeric vector of weights for each observation (NULL = equal weights).

Value

Numeric vector: gradient of the negative log-likelihood with respect to params.


cNORM documentation built on July 20, 2026, 5:07 p.m.