% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/negbin_helpers.R
\name{negbin_schur_correction}
\alias{negbin_schur_correction}
\title{NB Schur Correction}
\usage{
negbin_schur_correction(
  X,
  y,
  B,
  dispersion,
  order_list,
  K,
  family,
  observation_weights
)
}
\arguments{
\item{X}{List of partition design matrices.}

\item{y}{List of partition response vectors.}

\item{B}{List of partition coefficient vectors.}

\item{dispersion}{Scalar shape parameter \eqn{\theta}.}

\item{order_list}{List of observation indices per partition.}

\item{K}{Number of knots.}

\item{family}{Family object.}

\item{observation_weights}{Observation weights.}
}
\value{
List of K+1 correction matrices, with \code{0} for empty
  partitions.
}
\description{
Computes the Schur complement correction to account for uncertainty in
estimating \eqn{\theta}. Structure is identical to
\code{\link{weibull_schur_correction}}: the joint information is
partitioned into \eqn{(\boldsymbol{\beta}, \theta)} blocks and the
correction is \eqn{-\mathbf{I}_{\beta\theta}
I_{\theta\theta}^{-1}\mathbf{I}_{\beta\theta}^{\top}}.
}
\details{
The cross-derivative (score of \eqn{\eta_i} w.r.t. \eqn{\theta}) is
\deqn{\frac{\partial^2 \ell}{\partial \eta_i \partial \theta}
  = \frac{(y_i - \mu_i)\mu_i}{(\theta + \mu_i)^2}}
The second derivative of the log-likelihood w.r.t. \eqn{\theta} is
\deqn{I_{\theta\theta} = -\sum_i w_i \bigl[
  \psi'(y_i + \theta) - \psi'(\theta) +
  \frac{1}{\theta} - \frac{2}{\mu_i + \theta} +
  \frac{y_i + \theta}{(\mu_i + \theta)^2}\bigr]}
where \eqn{\psi'} is the trigamma function.
}
