negbin_dispersion_function: NB Dispersion Function

View source: R/negbin_helpers.R

negbin_dispersion_functionR Documentation

NB Dispersion Function

Description

Estimates the shape parameter \theta from current fitted values. When a correlation structure is present (VhalfInv is non-NULL), the Pearson residuals are whitened before computing the moment-based initial value, giving a better starting point for the profile MLE under correlated data. The final estimate is always the profile MLE over \theta.

Usage

negbin_dispersion_function(
  mu,
  y,
  order_indices,
  family,
  observation_weights,
  VhalfInv
)

Arguments

mu

Predicted values.

y

Observed counts.

order_indices

Observation indices.

family

NB family object.

observation_weights

Observation weights.

VhalfInv

Inverse square root of the correlation matrix, or NULL for independent observations. When non-NULL, used to whiten residuals for the moment-based initialization of \theta.

Details

The profile MLE maximizes \ell(\theta \mid \mu) via Brent's method. When VhalfInv is provided, the Pearson residuals r_i = (y_i - \mu_i) / \sqrt{V(\mu_i)} are pre-whitened as \tilde{r} = V^{-1/2} r before computing the moment estimator used for initialization. This accounts for the correlation structure in the variance decomposition and produces a more stable starting point for the optimizer, particularly when the correlation inflates the marginal variance beyond what the NB model alone would predict.

The profile MLE itself does not use VhalfInv because the NB log-likelihood is a marginal quantity; the correlation structure affects estimation only through the mean model (handled by the GEE paths in get_B).

Value

Scalar \theta estimate (stored as sigmasq_tilde).


lgspline documentation built on May 8, 2026, 5:07 p.m.