Numerical Optimization in Statistics: Newton–Raphson, Fisher Scoring, Nelder–Mead, and the EM Algorithm
Optimization landscapes: convexity, gradients, Hessian positive definiteness, and condition numbers; Unconstrained algorithms: Gradient Descent, Newton-Raphson method, and backtracking line search; Fisher Scoring and Iteratively Reweighted Least Squares (IRLS) for Generalized Linear Models; Derivative-free Nelder-Mead simplex algorithm: reflection, expansion, contraction, and shrink; Expectation-Maximization (EM) algorithm: latent variables, Q-function, Jensen's inequality proof of monotonic ascent, and Gaussian Mixture Models.
§7.1 Optimization Landscapes in Statistical Estimation: Convexity, Information Matrices, and Curvature
In parametric statistical theory, estimating unknown model parameters almost invariably reduces to an optimization problem. Whether fitting a Generalized Linear Model (GLM) via Maximum Likelihood Estimation (MLE), training a support vector machine via quadratic programming, minimizing penalized sum-of-squares in regularized regression (Ridge, Lasso), or calibrating deep neural networks, computational algorithms must locate the optimal parameter vector $\boldsymbol{\theta}^* \in \mathbb{R}^p$ that extremizes an objective criterion:
where $\ell(\boldsymbol{\theta}) = \ln L(\boldsymbol{\theta} \mid \mathbf{y})$ represents the log-likelihood function of the observed data.
Unlike general mathematical programming, statistical optimization exhibits unique geometric characteristics governed by information geometry, sample sizes, and the Fisher information metric.
Gradient Vectors and the Score Function
Let $\ell(\boldsymbol{\theta})$ be a twice-continuously differentiable log-likelihood function defined over an open parameter space $\Theta \subseteq \mathbb{R}^p$.
The first-order partial derivatives form the Gradient Vector, known in mathematical statistics as the Score Vector $\mathbf{S}(\boldsymbol{\theta}) = \mathbf{g}(\boldsymbol{\theta}) \in \mathbb{R}^p$:
At the Maximum Likelihood Estimate $\hat{\boldsymbol{\theta}}$, Fermat's stationary condition requires the score vector to vanish:
The Hessian Matrix and Observed vs Expected Information
The second-order partial derivatives characterize the local geometric curvature of the objective function. They form the symmetric $p \times p$ Hessian Matrix $\mathbf{H}(\boldsymbol{\theta}) \in \mathbb{R}^{p \times p}$:
In statistical estimation, we distinguish between two fundamental information matrices:
1. The Observed Information Matrix $\mathcal{J}(\boldsymbol{\theta})$:
The negative of the Hessian matrix evaluated at the parameter point:
The observed information measures the sample-specific local curvature of the log-likelihood surface around $\boldsymbol{\theta}$. If the observed information is large and positive definite, the log-likelihood surface drops off sharply around the peak, indicating that the sample data constrains the parameter tightly with small standard errors.
2. The Expected (Fisher) Information Matrix $\mathcal{I}(\boldsymbol{\theta})$:
The mathematical expectation of the observed information over the data-generating distribution:
Under standard Fisher regularity conditions:
- The support of the distribution $\mathcal{X}$ does not depend on parameter $\boldsymbol{\theta}$.
- The log-likelihood is twice differentiable with exchangeable integration and differentiation.
The expected information satisfies the fundamental Information Identity:
Because $\mathcal{I}(\boldsymbol{\theta})$ is the covariance matrix of the score vector, it is strictly positive semi-definite (PSD) everywhere across the parameter space:
This guarantee of positive semi-definiteness is a massive computational advantage of Fisher scoring over standard Newton–Raphson.
Convexity, Condition Numbers, and Ill-Conditioned Valleys
An objective function $f(\boldsymbol{\theta})$ is strictly convex on $\Theta$ if for all $\boldsymbol{\theta}_1 \ne \boldsymbol{\theta}_2$ and $\alpha \in (0, 1)$:
Equivalently, for twice-differentiable functions, convexity is characterized by the Hessian:
For strictly convex optimization problems (such as Ordinary Least Squares, Logistic Regression, Poisson GLMs with canonical links, and Lasso regression), any local minimum is guaranteed to be the unique global minimum.
The Condition Number of the Hessian:
The difficulty of minimizing a convex quadratic function $f(\boldsymbol{\theta}) \approx \frac{1}{2} \boldsymbol{\theta}^\top \mathbf{A} \boldsymbol{\theta}$ is governed by the Condition Number of the Hessian:
- If $\kappa \approx 1$, the contour level sets are spherical circles. Gradient descent steps point directly toward the global minimum.
- If $\kappa \gg 1$ (e.g. $\kappa = 10^6$, common in collinear statistical models), the level sets form elongated, narrow ellipsoidal ravines. First-order gradient methods oscillate violently from side to side across the steep canyon walls while making glacial progress along the flat valley floor (the "zigzagging" pathology).
§7.2 Gradient-Based Unconstrained Optimization: Gradient Descent, Newton–Raphson, and Quasi-Newton (BFGS)
To locate the optimum of an unconstrained statistical objective function, iterative descent algorithms generate a sequence of parameter vectors $\boldsymbol{\theta}^{(0)}, \boldsymbol{\theta}^{(1)}, \dots, \boldsymbol{\theta}^{(t)}$ that monotonically improve the criterion.
Gradient Descent and Line Search Strategies
To minimize a cost function $f(\boldsymbol{\theta})$ (or maximize $\ell(\boldsymbol{\theta})$), the Gradient Descent algorithm steps in the direction of steepest local descent:
where $\gamma_t > 0$ is the step size (learning rate).
Step Size Selection and the Backtracking Armijo Line Search:
Choosing a fixed step size $\gamma$ is perilous: if $\gamma$ is too small, convergence takes millions of iterations; if $\gamma$ is too large, the algorithm overshoots the minimum and diverges to infinity.
To guarantee robust convergence, modern optimization deploys the Armijo Backtracking Line Search:
- Choose baseline parameters: contraction factor $\tau \in (0, 1)$ (typically $\tau = 0.5$) and sufficient decrease factor $c \in (0, 1)$ (typically $c = 10^{-4}$).
- Start with trial step $\gamma = 1.0$.
- Check the Armijo Condition:
- If the condition is violated, shrink the step: $\gamma \leftarrow \tau \gamma$, and repeat until sufficient decrease is achieved.
Gradient descent with Armijo backtracking exhibits guaranteed convergence to a stationary point, but its asymptotic rate of convergence is strictly linear:
When $\kappa$ is large, $\frac{\kappa - 1}{\kappa + 1} \approx 1 - \frac{2}{\kappa}$, making convergence painfully slow.
The Newton–Raphson Algorithm
To overcome the linear convergence limitation of gradient descent, the Newton–Raphson Method incorporates second-order curvature information.
Quadratic Taylor Series Approximation:
Approximate the log-likelihood function $\ell(\boldsymbol{\theta})$ around current estimate $\boldsymbol{\theta}^{(t)}$ using a second-order Taylor expansion:
Differentiating with respect to $\boldsymbol{\theta}$ and setting the gradient to zero:
Solving for $\boldsymbol{\theta}$ yields the Newton–Raphson Update Equation:
Newton-Raphson Quadratic Leap:
Objective ^
| True Objective Function f(\theta)
| .-----------------------------.
| / \
| / Quadratic Model Q(\theta) \
| / .-----------------------. \
| / / \ \
0.0 +---+---+---------------------------+-------+---> \theta
\theta^{(t)} \theta^{(t+1)}
(Current) (Exact Minimum of Q)
The Quadratic Convergence Property:
If $\boldsymbol{\theta}^{(0)}$ is sufficiently close to $\boldsymbol{\theta}^*$ and the Hessian $\mathbf{H}(\boldsymbol{\theta}^*)$ is non-singular, Newton–Raphson converges with quadratic convergence speed:
Each iteration approximately doubles the number of accurate significant digits! Once inside the basin of attraction, the algorithm terminates in 4 to 6 iterations.
Severe Breakdown Modes of Newton–Raphson:
1. Non-Positive Definite Hessians: Far from the optimum in non-convex landscapes, $\mathbf{H}(\boldsymbol{\theta}^{(t)})$ may have negative eigenvalues. The Newton step then climbs toward a local maximum or saddle point rather than descending!
2. Computational Scaling: Evaluating the exact analytical Hessian requires computing $p(p+1)/2$ second derivatives. Solving the linear system $\mathbf{H} \boldsymbol{\Delta} = -\mathbf{g}$ via Cholesky or LU factorization costs $\mathcal{O}(p^3)$ FLOPs per step. When $p = 10,000$, a single Newton step requires $10^{12}$ operations, becoming computationally impossible.
Quasi-Newton Methods: BFGS and Limited-Memory L-BFGS
To achieve super-linear convergence without computing or inverting the full $p \times p$ Hessian matrix at each step, Charles Broyden, Roger Fletcher, Donald Goldfarb, and David Shanno (1970) formulated the BFGS Algorithm.
Instead of computing $\mathbf{H}^{-1}$ explicitly, BFGS maintains a running symmetric positive-definite approximation of the inverse Hessian matrix $\mathbf{B}_t \approx [\nabla^2 f(\boldsymbol{\theta}^{(t)})]^{-1}$.
The BFGS Update Formula:
Let $\mathbf{s}_t = \boldsymbol{\theta}^{(t+1)} - \boldsymbol{\theta}^{(t)}$ denote the parameter displacement, and $\mathbf{y}_t = \mathbf{g}_{t+1} - \mathbf{g}_t$ denote the gradient displacement. The updated inverse Hessian approximation $\mathbf{B}_{t+1}$ must satisfy the Secant Equation:
BFGS constructs the unique symmetric rank-two update that preserves positive definiteness:
where $\rho_t = \frac{1}{\mathbf{y}_t^\top \mathbf{s}_t}$.
- Each step requires only matrix-vector multiplications ($\mathcal{O}(p^2)$ operations instead of $\mathcal{O}(p^3)$).
- L-BFGS (Limited-Memory BFGS): For massive models, storing $\mathbf{B}_t$ ($p \times p$ numbers) is impossible. L-BFGS stores only the last $m$ displacement vectors $\{\mathbf{s}_k, \mathbf{y}_k\}_{k=t-m}^t$ (typically $m \in [5, 20]$), computing the search direction via a two-loop recursion in strictly $\mathcal{O}(m p)$ memory and time.
§7.3 Fisher Scoring and Iteratively Reweighted Least Squares (IRLS) for GLMs
In statistical modeling, Generalized Linear Models (GLMs), developed by John Nelder and Robert Wedderburn in 1972, extend classical linear regression to non-Gaussian exponential dispersion families (Binomial, Poisson, Gamma, Inverse Gaussian).
To fit GLMs, statisticians deploy a specialized second-order algorithm known as Fisher Scoring, which translates optimization directly into an iterative weighted least-squares problem: Iteratively Reweighted Least Squares (IRLS).
Fisher Scoring Algorithm
The Fisher Scoring Method replaces the sample-dependent observed information matrix $\mathcal{J}(\boldsymbol{\theta}) = -\mathbf{H}(\boldsymbol{\theta})$ in Newton–Raphson with the Expected (Fisher) Information Matrix $\mathcal{I}(\boldsymbol{\theta})$:
Comparative Theoretical Virtues of Fisher Scoring vs Newton–Raphson:
1. Guaranteed Descent Direction: Because $\mathcal{I}(\boldsymbol{\theta})$ is the covariance matrix of the score vector, it is guaranteed to be positive semi-definite everywhere. The search direction $\mathbf{d} = \mathcal{I}^{-1} \mathbf{g}$ satisfies:
Fisher scoring can never climb in the wrong direction or get trapped by negative curvature.
2. Canonical Link Equivalence: When a GLM uses its canonical link function (e.g. logit for Binomial, log for Poisson), the observed information and expected information are mathematically identical:
Under canonical links, Fisher scoring and Newton–Raphson execute the exact same arithmetic steps.
The Exponential Dispersion Family and GLM Architecture
In a univariate GLM, the response variable $Y_i$ has a distribution belonging to the Exponential Dispersion Family with density:
where:
- $\theta_i$ is the natural (canonical) parameter.
- $b(\theta_i)$ is the cumulant generator function.
- $\phi$ is the dispersion parameter.
By standard properties of exponential families:
where $V(\mu)$ is the variance function.
The GLM links the linear predictor $\eta_i = \mathbf{x}_i^\top \boldsymbol{\beta}$ to the mean $\mu_i$ via a monotonic, differentiable link function $g(\cdot)$:
Derivation of the IRLS Algorithm
Let us derive the score vector and Fisher information matrix for parameter vector $\boldsymbol{\beta} \in \mathbb{R}^p$.
1. The Score Vector:
Using the chain rule:
Notice that:
- $\frac{\partial \ell_i}{\partial \theta_i} = \frac{y_i - b'(\theta_i)}{a(\phi)} = \frac{y_i - \mu_i}{a(\phi)}$.
- Since $\mu_i = b'(\theta_i)$, $\frac{\partial \mu_i}{\partial \theta_i} = b''(\theta_i) = V(\mu_i) \implies \frac{\partial \theta_i}{\partial \mu_i} = \frac{1}{V(\mu_i)}$.
- $\frac{\partial \eta_i}{\partial \beta_j} = x_{ij}$.
- Let $g'(\mu_i) = \frac{\partial \eta_i}{\partial \mu_i}$, so $\frac{\partial \mu_i}{\partial \eta_i} = \frac{1}{g'(\mu_i)}$.
Combining terms:
Define the working weights $W_i$:
In matrix notation, let $\mathbf{W} = \text{diag}(W_1, \dots, W_n) \in \mathbb{R}^{n \times n}$.
The overall score vector across all $n$ observations is:
where $\mathbf{D} = \text{diag}(g'(\mu_1), \dots, g'(\mu_n))$.
2. The Fisher Information Matrix:
The Expected Information Matrix is:
3. The Fisher Scoring Step as Weighted Least Squares:
Substitute $\mathbf{g}$ and $\mathcal{I}$ into the Fisher scoring equation:
Factor out $(\mathbf{X}^\top \mathbf{W}_t \mathbf{X})^{-1} \mathbf{X}^\top \mathbf{W}_t$:
Define the adjusted working response vector $\mathbf{z}_t \in \mathbb{R}^n$:
The update equation simplifies to:
This is the exact mathematical solution to a Weighted Least Squares (WLS) regression of the working response $\mathbf{z}_t$ on the design matrix $\mathbf{X}$ with diagonal weight matrix $\mathbf{W}_t$!
The IRLS Loop:
- Initialize $\boldsymbol{\beta}^{(0)}$ (or initialize $\mu_i^{(0)} = y_i + \delta$).
- Compute linear predictors $\eta_{i, t} = \mathbf{x}_i^\top \boldsymbol{\beta}^{(t)}$ and fitted means $\mu_{i, t} = g^{-1}(\eta_{i, t})$.
- Compute working weights $W_{i, t} = \frac{1}{V(\mu_{i, t}) [g'(\mu_{i, t})]^2}$ and working responses $z_{i, t} = \eta_{i, t} + (y_i - \mu_{i, t}) g'(\mu_{i, t})$.
- Solve the weighted least squares problem $\boldsymbol{\beta}^{(t+1)} = (\mathbf{X}^\top \mathbf{W}_t \mathbf{X})^{-1} \mathbf{X}^\top \mathbf{W}_t \mathbf{z}_t$ via Householder QR.
- Repeat until $\|\boldsymbol{\beta}^{(t+1)} - \boldsymbol{\beta}^{(t)}\|_\infty < \epsilon$.
This celebrated derivation explains why `glm()` in R and `statsmodels.api.GLM` in Python execute so efficiently: every iteration leverages highly optimized compiled QR routines for weighted regression.
§7.4 Derivative-Free Optimization: The Nelder–Mead Simplex Algorithm
In many complex statistical settings, computing analytical gradients $\mathbf{g}(\boldsymbol{\theta})$ or Hessians $\mathbf{H}(\boldsymbol{\theta})$ is impossible. For example, the likelihood function may be evaluated via stochastic Monte Carlo simulation (Simulated Method of Moments), black-box physics codes, or non-smooth step functions.
In 1965, John Nelder and Roger Mead developed the Nelder–Mead Simplex Algorithm (the default optimization method of `optim(method = "Nelder-Mead")` in R and `scipy.optimize.minimize(method = "Nelder-Mead")` in Python).
Nelder–Mead is a derivative-free heuristic that adapts a geometric simplex to the local contours of the objective surface.
Anatomy of a Simplex
In a $p$-dimensional parameter space $\mathbb{R}^p$, a simplex is a geometric polytope formed by $p + 1$ distinct vertex vectors:
- In $p = 1$ dimension, a simplex is a line segment (2 vertices).
- In $p = 2$ dimensions, a simplex is a triangle (3 vertices).
- In $p = 3$ dimensions, a simplex is a tetrahedron (4 vertices).
At each iteration, the objective function $f(\mathbf{x})$ is evaluated at all $p + 1$ vertices, and the vertices are sorted in ascending order of function values:
We define:
- $\mathbf{x}_1$: The best vertex ($\mathbf{x}_l$, lowest cost).
- $\mathbf{x}_p$: The second-worst vertex ($\mathbf{x}_s$).
- $\mathbf{x}_{p+1}$: The worst vertex ($\mathbf{x}_h$, highest cost).
- $\bar{\mathbf{x}}$: The centroid of all vertices excluding the worst vertex:
The Four Fundamental Geometric Transformations
The algorithm attempts to replace the worst vertex $\mathbf{x}_{p+1}$ with a superior point using four geometric transformations governed by standard tuning parameters $(\alpha, \gamma, \rho, \sigma) = (1.0, 2.0, 0.5, 0.5)$:
Nelder-Mead Geometric Transformations:
x_e (Expansion: gamma=2.0)
^
|
x_r (Reflection: alpha=1.0)
^
|
[Centroid \bar{x}]
/ \
x_1 x_2
\ /
x_{p+1} (Worst Vertex)
1. Reflection ($\alpha = 1.0$):
Reflect the worst vertex through the centroid:
Evaluate $f_r = f(\mathbf{x}_r)$.
- If $f(\mathbf{x}_1) \le f_r < f(\mathbf{x}_p)$: The reflected point is better than the second-worst, but not strictly the best. Replace $\mathbf{x}_{p+1} \leftarrow \mathbf{x}_r$, and terminate the iteration.
2. Expansion ($\gamma = 2.0$):
If the reflected point is strictly better than the current best ($f_r < f(\mathbf{x}_1)$), the search direction is highly promising. Expand further along the ray:
Evaluate $f_e = f(\mathbf{x}_e)$.
- If $f_e < f_r$: Replace $\mathbf{x}_{p+1} \leftarrow \mathbf{x}_e$.
- Otherwise: Replace $\mathbf{x}_{p+1} \leftarrow \mathbf{x}_r$.
3. Contraction ($\rho = 0.5$):
If the reflected point is worse than the second-worst ($f_r \ge f(\mathbf{x}_p)$), the simplex has overshot the valley. Perform a contraction:
- Outside Contraction ($f(\mathbf{x}_p) \le f_r < f(\mathbf{x}_{p+1})$):
If $f(\mathbf{x}_{oc}) \le f_r$, accept $\mathbf{x}_{p+1} \leftarrow \mathbf{x}_{oc}$.
- Inside Contraction ($f_r \ge f(\mathbf{x}_{p+1})$):
If $f(\mathbf{x}_{ic}) < f(\mathbf{x}_{p+1})$, accept $\mathbf{x}_{p+1} \leftarrow \mathbf{x}_{ic}$.
4. Shrink ($\sigma = 0.5$):
If contraction fails to produce a point better than the worst vertex, the simplex shrinks all vertices toward the best point $\mathbf{x}_1$:
Shrinking requires evaluating the objective function at $p$ new points.
Convergence Properties:
Nelder–Mead is robust and requires zero derivatives. However, it is a heuristic: in dimensions $p > 20$, the simplex frequently collapses into a degenerate lower-dimensional subspace or stalls at non-stationary points.
§7.5 The Expectation–Maximization (EM) Algorithm: Latent Variables, Jensen's Inequality, and Monotonic Convergence
In many statistical models, maximum likelihood estimation is complicated by the presence of latent (unobserved) variables or missing data. Canonical examples include:
- Gaussian Mixture Models (where cluster memberships are unobserved).
- Censored survival times.
- Hidden Markov Models (HMMs).
- Factor analysis.
In 1977, Arthur Dempster, Nan Laird, and Donald Rubin published their seminal paper formulating the Expectation–Maximization (EM) Algorithm. The EM algorithm transforms an intractable incomplete-data optimization problem into a sequence of simple complete-data optimizations with guaranteed monotonic likelihood convergence.
Mathematical Framework: Incomplete vs Complete Data
Let:
- $\mathbf{Y}$: The observed data vector.
- $\mathbf{Z}$: The unobserved latent data (or missing data).
- $\mathbf{X} = (\mathbf{Y}, \mathbf{Z})$: The hypothetical complete data.
The goal is to compute the Maximum Likelihood Estimate of parameter $\boldsymbol{\theta}$ based on the observed data log-likelihood:
Because the integral (or sum) appears inside the logarithm, the observed log-likelihood $\ln \int \dots$ does not decouple into simple additive terms, making direct differentiation intractable.
Conversely, the complete-data log-likelihood:
belongs to a simple exponential family that would be trivial to maximize if $\mathbf{Z}$ were known.
The EM Master Function: The Q-Function
Because $\mathbf{Z}$ is unknown, we cannot maximize $\ell_c(\boldsymbol{\theta} \mid \mathbf{Y}, \mathbf{Z})$ directly. Instead, the EM algorithm takes the conditional expectation of the complete log-likelihood with respect to the latent variables $\mathbf{Z}$, conditioned on the observed data $\mathbf{Y}$ and current parameter estimate $\boldsymbol{\theta}^{(t)}$.
The central mathematical object of the EM algorithm is the $Q$-Function:
The EM Iteration Cycle:
Current Parameter \theta^{(t)}
|
v
[ Expectation (E-step) ]
|
v Compute Q(\theta | \theta^{(t)})
[ Maximization (M-step) ]
|
v \theta^{(t+1)} = argmax Q(\theta | \theta^{(t)})
Updated Parameter \theta^{(t+1)} (Guaranteed: \ell(\theta^{(t+1)}) >= \ell(\theta^{(t)}))
The Two-Step Algorithmic Cycle:
1. The Expectation Step (E-step):
Calculate the conditional distribution of the latent variables given the current parameter estimate:
and formulate the expected complete-data log-likelihood $Q(\boldsymbol{\theta} \mid \boldsymbol{\theta}^{(t)})$.
2. The Maximization Step (M-step):
Update the parameter estimate by globally maximizing the $Q$-function:
Proof of Monotonic Likelihood Ascent via Jensen's Inequality
The defining theoretical property of the EM algorithm is that the observed log-likelihood increases monotonically at every single iteration:
Rigorous Mathematical Proof:
Express the complete joint density as the product of the marginal and conditional densities:
Taking the natural logarithm of both sides:
Rearranging for the observed log-likelihood $\ell(\boldsymbol{\theta}) = \ln p(\mathbf{Y} \mid \boldsymbol{\theta})$:
Take the conditional expectation of both sides with respect to $p(\mathbf{Z} \mid \mathbf{Y}, \boldsymbol{\theta}^{(t)})$:
Because $\ell(\boldsymbol{\theta})$ does not depend on $\mathbf{Z}$, its expectation is simply $\ell(\boldsymbol{\theta})$:
where:
Now evaluate the change in log-likelihood from step $t$ to step $t+1$:
We evaluate the two bracketed terms separately:
1. First Term ($Q$-Difference):
By definition of the M-step, $\boldsymbol{\theta}^{(t+1)}$ maximizes $Q(\boldsymbol{\theta} \mid \boldsymbol{\theta}^{(t)})$. Therefore:
2. Second Term ($H$-Difference and Jensen's Inequality):
Consider the difference:
Recall that the natural logarithm is a strictly concave function ($\ln''(x) = -1/x^2 < 0$). By Jensen's Inequality, for any concave function $\phi$, $\mathbb{E}[\phi(X)] \le \phi(\mathbb{E}[X])$. Therefore:
The terms $p(\mathbf{z} \mid \mathbf{Y}, \boldsymbol{\theta}^{(t)})$ cancel in the integral:
Thus:
Combining both inequalities:
This completes the mathematical proof that the observed log-likelihood increases monotonically at every single EM step.
§7.6 Gaussian Mixture Models, Latent Cluster Responsibilities, and EM Singularities
In multivariate cluster analysis and density estimation, observations often originate from a heterogeneous combination of $K$ unobserved sub-populations. The canonical parametric framework for unsupervised clustering is the Gaussian Mixture Model (GMM). Because component memberships are unobserved latent variables, maximum likelihood estimation is executed via the Expectation–Maximization (EM) algorithm.
Formulation of the Gaussian Mixture Model
Let $\mathbf{y}_1, \dots, \mathbf{y}_n \in \mathbb{R}^d$ be an i.i.d. sample drawn from a mixture of $K$ multivariate Gaussian components:
where:
- $\pi_k \in (0, 1)$ are the mixture proportions (mixing weights), satisfying $\sum_{k=1}^K \pi_k = 1$.
- $\boldsymbol{\mu}_k \in \mathbb{R}^d$ is the mean vector of component $k$.
- $\boldsymbol{\Sigma}_k \in \mathbb{R}^{d \times d}$ is the symmetric positive-definite covariance matrix of component $k$.
- $\mathcal{N}(\mathbf{y} \mid \boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k) = \frac{1}{(2\pi)^{d/2} |\boldsymbol{\Sigma}_k|^{1/2}} \exp\left( -\frac{1}{2} (\mathbf{y} - \boldsymbol{\mu}_k)^\top \boldsymbol{\Sigma}_k^{-1} (\mathbf{y} - \boldsymbol{\mu}_k) \right)$.
The complete parameter set is $\boldsymbol{\theta} = \{ \pi_k, \boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k \}_{k=1}^K$.
Latent Variable Encoding:
For each observation $i \in \{1, \dots, n\}$, introduce a binary latent indicator vector $\mathbf{z}_i = (z_{i1}, \dots, z_{iK})^\top \in \{0, 1\}^K$, where $z_{ik} = 1$ if observation $i$ was generated by component $k$, and $z_{ik} = 0$ otherwise:
The complete-data joint likelihood for the pair $(\mathbf{y}_i, \mathbf{z}_i)$ is:
Taking the logarithm yields the complete-data log-likelihood:
The EM Steps for GMM
1. The E-Step (Computing Latent Responsibilities):
In the E-step, we evaluate the conditional expectation of the latent variables $z_{ik}$ given the observed data $\mathbf{y}_i$ and current parameters $\boldsymbol{\theta}^{(t)}$. Because $z_{ik} \in \{0, 1\}$, its conditional expectation is simply the posterior probability that observation $i$ belongs to component $k$, termed the responsibility $\gamma_{ik}^{(t)}$:
By Bayes' theorem:
Notice that $\sum_{k=1}^K \gamma_{ik} = 1$ for each observation $i$, representing a "soft" probabilistic assignment across the $K$ clusters.
2. The M-Step (Closed-Form Parameter Maximization):
Substituting $\gamma_{ik}^{(t)}$ into the expected complete log-likelihood:
Maximizing $Q$ with respect to each parameter yields closed-form update equations:
1. Effective Component Sample Size:
2. Updated Mixture Proportions:
Maximizing with respect to $\pi_k$ subject to $\sum \pi_k = 1$ using Lagrange multipliers:
3. Updated Component Means:
Setting $\nabla_{\boldsymbol{\mu}_k} Q = \mathbf{0}$:
The new mean is a weighted average of all observed data points, weighted by cluster responsibilities!
4. Updated Component Covariances:
Setting $\nabla_{\boldsymbol{\Sigma}_k^{-1}} Q = \mathbf{0}$:
Likelihood Singularities and Practical Safeguards
A critical pathology of the Gaussian Mixture Model is that the unconstrained likelihood function is unbounded from above:
The Mechanism of Component Collapse:
Suppose during EM iterations, component mean $\boldsymbol{\mu}_k$ becomes exactly equal to a single data point $\mathbf{y}_m$ ($\boldsymbol{\mu}_k = \mathbf{y}_m$), and its variance $\sigma_k^2 \to 0$. The likelihood contribution of observation $m$ evaluates to:
Even if the other $n - 1$ points have finite densities, the total likelihood explodes to infinity! This is not a true global maximum in a statistical sense; it is a spurious singularity of the parameterization.
Practical Remediation in Software:
1. Covariance Regularization (Tikhonov Regularization):
Add a tiny diagonal ridge to the covariance matrix at every M-step:
This prevents the determinant $|\boldsymbol{\Sigma}_k|$ from dropping to zero.
2. K-Means++ Initialization:
The EM algorithm is sensitive to starting points. Initializing component means $\boldsymbol{\mu}_k^{(0)}$ using the $k$-means++ algorithm (which spaces initial centroids far apart based on squared Euclidean distance) dramatically accelerates convergence and avoids spurious local maxima.
§7.7 Modern Stochastic and Non-Smooth Optimization: SGD, Adam, and Proximal Gradients for the Lasso
In modern data science and deep statistical learning, dataset sizes often scale to millions of records ($n = 10^7$). In these settings, standard batch optimization (where evaluating the full gradient $\nabla \ell(\boldsymbol{\theta}) = \sum_{i=1}^n \nabla \ell_i(\boldsymbol{\theta})$ requires a complete pass over the entire multi-gigabyte dataset) is computationally intractable for each iterative step.
Furthermore, penalized estimators such as the Lasso ($L_1$ penalty) introduce non-differentiable absolute value singularities that break classical gradient descent and Newton–Raphson.
Stochastic Gradient Descent (SGD) and Mini-Batching
In 1951, Herbert Robbins and Sutton Monro published the foundational theory of Stochastic Approximation. Instead of computing the exact full-sample gradient over all $n$ observations:
Stochastic Gradient Descent (SGD) computes an unbiased gradient estimate using a small random mini-batch of observations $\mathcal{B} \subset \{1, \dots, n\}$ of size $B = |\mathcal{B}|$ (typically $B \in [32, 512]$):
Notice that:
The mini-batch gradient is an unbiased estimator of the true population gradient!
The Robbins–Monro Learning Rate Conditions:
To guarantee that the noisy stochastic steps converge almost surely to the true stationary point $\boldsymbol{\theta}^*$, the step size sequence $\gamma_t$ must satisfy the Robbins–Monro conditions:
- $\sum \gamma_t = \infty$ ensures the algorithm can travel arbitrarily far from the initial point.
- $\sum \gamma_t^2 < \infty$ ensures the cumulative variance of the stochastic gradient noise diminishes to zero, damping oscillations as the optimum is approached. A standard decaying schedule is $\gamma_t = \gamma_0 / (1 + \lambda t)$ or $\gamma_t = \gamma_0 t^{-0.51}$.
Adaptive Moment Estimation (Adam)
In deep learning and complex non-convex neural estimation, standard SGD struggles with disparate gradient scales across features. In 2014, Diederik Kingma and Jimmy Ba introduced Adam (Adaptive Moment Estimation).
Adam combines the physical concept of Momentum (exponential moving average of past gradients) with RMSProp (exponential moving average of squared past gradients), maintaining element-wise adaptive learning rates.
The Adam Algorithmic Recurrence:
At iteration $t$ with stochastic gradient $\mathbf{g}_t$:
1. Update Biased First Moment (Direction / Momentum):
2. Update Biased Second Raw Moment (Uncentered Variance):
where $\mathbf{g}_t^{\odot 2}$ denotes element-wise squaring ($g_{t, j}^2$).
3. Compute Bias-Corrected Moments:
Because $\mathbf{m}_0 = \mathbf{0}$ and $\mathbf{v}_0 = \mathbf{0}$, the moving averages are biased toward zero in initial iterations. The exact analytical bias corrections are:
4. Update Parameter Vector:
where $\eta$ is the base step size (typically $10^{-3}$) and $\epsilon \approx 10^{-8}$ prevents division by zero.
Adam automatically scales down steps for parameters with large, erratic gradients while boosting progress along flat, subtle directions, making it the universal default optimizer for modern deep neural networks.
Proximal Gradient Descent for Non-Smooth Regularization (Lasso)
In high-dimensional penalized regression, the Lasso (Least Absolute Shrinkage and Selection Operator), introduced by Robert Tibshirani in 1996, minimizes the regularized objective:
where $\|\boldsymbol{\beta}\|_1 = \sum_{j=1}^p |\beta_j|$.
The Non-Smooth Singularity:
The function $|\beta_j|$ has a sharp corner at $\beta_j = 0$. The derivative does not exist at zero, meaning standard gradient descent $\nabla f(\boldsymbol{\beta})$ is undefined!
To optimize non-smooth composite objectives $f(\boldsymbol{\beta}) = g(\boldsymbol{\beta}) + h(\boldsymbol{\beta})$ (where $g$ is smooth and convex, and $h$ is convex but non-differentiable), numerical analysts deploy Proximal Gradient Descent.
The Proximal Operator and Soft-Thresholding:
The proximal operator of the scaled $L_1$ penalty $\lambda \|\boldsymbol{\beta}\|_1$ with step size $\gamma$ is the Soft-Thresholding Operator:
where the scalar soft-thresholding function is defined as:
Soft-Thresholding Operator S_\tau(u):
Output ^
| / (Slope = 1)
| /
| .----'
-------+-------+------+-------> u
-\tau 0.0 +\tau
| '----.
| \
| \ (Slope = 1)
Notice that for any input within the threshold window $[-\tau, \tau]$, the operator sets the value identically to zero! This is the exact mathematical mechanism that drives sparse feature selection in the Lasso.
The Iterative Shrinkage-Thresholding Algorithm (ISTA):
Each iteration executes a two-phase step:
1. Gradient Step on Smooth Loss:
2. Proximal Projection (Soft-Thresholding):
Fast Iterative Shrinkage-Thresholding Algorithm (FISTA):
Standard ISTA converges at a linear rate of $\mathcal{O}(1/k)$. In 2009, Amir Beck and Marc Teboulle applied Nesterov Momentum Acceleration to construct FISTA:
FISTA achieves optimal accelerated convergence of $\mathcal{O}(1/k^2)$, allowing high-dimensional sparse regressions with tens of thousands of features to be solved in seconds.
§7.8 Constrained Optimization: Karush–Kuhn–Tucker Conditions, Barrier Methods, and Augmented Lagrangians
Many statistical estimation problems impose physical, biological, or mathematical constraints on the parameter vector:
- Non-negativity: $\beta_j \ge 0$ (e.g. concentrations, non-negative matrix factorization).
- Probability simplex: $\sum \pi_k = 1, \pi_k \ge 0$ (mixture proportions, Markov transition matrices).
- Bounded parameter domains: $L_j \le \theta_j \le U_j$.
- Covariance positive definiteness: $\boldsymbol{\Sigma} \succ 0$.
The Karush–Kuhn–Tucker (KKT) Necessary Conditions
Consider the general constrained statistical optimization problem:
Define the Lagrangian function:
where $\lambda_i \ge 0$ are the Lagrange multipliers for inequality constraints and $\nu_j \in \mathbb{R}$ are multipliers for equality constraints.
The KKT First-Order Conditions:
At any local constrained minimum $\boldsymbol{\theta}^*$, under standard constraint qualifications (e.g. Slater's condition for convex problems), there exist multiplier vectors $\boldsymbol{\lambda}^*$ and $\boldsymbol{\nu}^*$ satisfying:
1. Stationarity:
2. Primal Feasibility:
3. Dual Feasibility:
4. Complementary Slackness:
The complementary slackness condition implies that either the constraint is strictly active (binding: $g_i(\boldsymbol{\theta}^*) = 0$), in which case its shadow price $\lambda_i^* \ge 0$; or the constraint is inactive ($g_i(\boldsymbol{\theta}^*) < 0$), in which case $\lambda_i^* = 0$.
Interior Point and Logarithmic Barrier Methods
For inequality constraints $g_i(\boldsymbol{\theta}) \le 0$, Interior Point Methods replace the hard constraints with a smooth Logarithmic Barrier Function:
The algorithm solves a sequence of unconstrained problems indexed by barrier parameter $\mu > 0$:
As $\boldsymbol{\theta}$ approaches the boundary of the feasible region ($g_i(\boldsymbol{\theta}) \to 0^-$), the logarithmic term $-\ln(-g_i) \to +\infty$, erecting an impassable barrier that prevents iterates from leaving the interior. By systematically shrinking $\mu \to 0$ (e.g. $\mu_{t+1} = 0.2 \mu_t$) and solving each sub-problem via Newton's method, the trajectory (central path) converges to the exact constrained optimum.
Coordinate Descent for Elastic Net and High-Dimensional Regression
For high-dimensional regularized regression models (Lasso, Elastic Net: $\lambda_1 \|\boldsymbol{\beta}\|_1 + \frac{\lambda_2}{2} \|\boldsymbol{\beta}\|_2^2$), Jerome Friedman, Trevor Hastie, and Robert Tibshirani (2007) popularized Coordinate Descent (the engine of the `glmnet` package in R and Python).
Instead of updating all $p$ coefficients simultaneously:
- Cycle through predictors $j = 1, 2, \dots, p$ one at a time.
- Holding all other coefficients $\boldsymbol{\beta}_{-j}$ fixed, solve the exact univariate sub-problem for $\beta_j$:
Because the univariate solution has a closed-form soft-thresholding expression, Coordinate Descent sweeps through thousands of variables in milliseconds, delivering state-of-the-art performance for sparse genomic regressions.
§7.9 Stochastic Variance Reduction: SVRG, SAGA, and Wolfe Line-Search Conditions
While Stochastic Gradient Descent (SGD) achieves rapid early progress in large-scale machine learning, its constant gradient noise variance $\mathbb{E}[\|\mathbf{g}_{\mathcal{B}} - \nabla f\|^2] \ge \sigma^2 > 0$ forces the algorithm to use decaying step sizes, slowing its asymptotic convergence rate from linear to sub-linear $\mathcal{O}(1/t)$.
To overcome this fundamental limitation, Rie Johnson and Tong Zhang (2013) formulated Stochastic Variance Reduced Gradient (SVRG), while Aaron Defazio, Francis Bach, and Simon Lacoste-Julien (2014) developed SAGA.
The SVRG Algorithmic Architecture
SVRG operates in two nested loops: an outer epoch loop and an inner stochastic update loop.
1. Outer Epoch Loop:
At the beginning of each epoch, compute the exact full-sample gradient across all $n$ observations at snapshot parameter $\tilde{\boldsymbol{\theta}}$:
2. Inner Stochastic Loop:
For $m$ steps (typically $m \approx 2n$), draw a single random observation index $i_t \in \{1, \dots, n\}$ and compute the variance-reduced gradient estimator:
Update the parameter:
Unbiasedness and Variance Decay:
Notice that:
The estimator $\mathbf{v}_t$ is strictly unbiased! Furthermore, as $\boldsymbol{\theta}_t$ and $\tilde{\boldsymbol{\theta}}$ both converge to the true optimum $\boldsymbol{\theta}^*$:
The variance of $\mathbf{v}_t$ asymptotically vanishes to zero ($\text{Var}(\mathbf{v}_t) \to 0$) without requiring step size decay! Consequently, SVRG achieves geometric linear convergence $\mathcal{O}(\rho^k)$ like full-batch gradient descent, while requiring only two gradient evaluations per step.
The Wolfe Conditions for Quasi-Newton Line Search
In Quasi-Newton optimization (BFGS / L-BFGS), inexact line searches along search direction $\mathbf{p}_k$ must choose step size $\alpha_k$ to satisfy the Wolfe Conditions:
1. Sufficient Decrease (Armijo Condition):
where $0 < c_1 < 1$ (typically $c_1 = 10^{-4}$). This prevents the step from being too large.
2. Curvature Condition:
where $c_1 < c_2 < 1$ (typically $c_2 = 0.9$ for BFGS). This guarantees that the slope has decreased sufficiently, preventing steps from being infinitesimally small.
The Strong Wolfe Conditions restrict the absolute curvature:
Satisfying the Strong Wolfe conditions guarantees that the displacement vectors $\mathbf{s}_k = \alpha_k \mathbf{p}_k$ and $\mathbf{y}_k = \nabla f_{k+1} - \nabla f_k$ satisfy the positive definiteness condition:
ensuring that the BFGS updated inverse Hessian approximation $\mathbf{B}_{k+1}$ remains strictly positive definite at every iteration.
§7.10 Global Optimization: Simulated Annealing and Trust-Region Methods in Statistics
In statistical estimation landscapes with complex multimodality, rugged surfaces, and non-differentiable thresholds—such as mixture models with unknown component counts, phylogenetics, changepoint detection, and non-linear pharmacokinetic models—local gradient-based methods (Newton–Raphson, BFGS) inevitably terminate in poor local optima.
To locate the true global extremum, computational statisticians deploy Global Optimization Heuristics and Trust-Region Methods.
Simulated Annealing (Kirkpatrick, Gelatt, and Vecchi, 1983)
Simulated Annealing adapts the physical thermodynamics of metal metallurgy to numerical optimization. In physical metallurgy, slow controlled cooling (annealing) allows atoms to escape high-energy crystalline defects and settle into the global minimum energy state.
Let $E(\boldsymbol{\theta}) = f(\boldsymbol{\theta})$ denote the objective function (energy). At iteration $t$ with current state $\boldsymbol{\theta}_t$ and temperature parameter $T_t > 0$:
- Generate a candidate proposal $\boldsymbol{\theta}^* = \boldsymbol{\theta}_t + \boldsymbol{\Delta}$ from a proposal distribution.
- Compute the energy difference: $\Delta E = f(\boldsymbol{\theta}^*) - f(\boldsymbol{\theta}_t)$.
- Evaluate the Metropolis Acceptance Criterion:
- If $\Delta E < 0$ (the proposed state improves the objective), ACCEPT unconditionally: $\boldsymbol{\theta}_{t+1} = \boldsymbol{\theta}^*$.
- If $\Delta E \ge 0$ (the proposed state worsens the objective), ACCEPT probabilistically with acceptance probability:
Draw $U \sim \text{Uniform}(0, 1)$. If $U \le \exp(-\Delta E / T_t)$, accept; otherwise reject.
The Crucial Role of Temperature and Cooling Schedules:
- At High Temperatures ($T \gg 1$): $\exp(-\Delta E / T) \approx 1$. The algorithm accepts virtually all uphill steps, exploring the global space freely and escaping local traps.
- At Low Temperatures ($T \to 0$): $\exp(-\Delta E / T) \to 0$. The algorithm accepts only downhill steps, converging greedily to the nearest local minimum.
The Hajek Convergence Theorem:
Bruce Hajek (1988) proved that Simulated Annealing is guaranteed to converge to the global minimum with probability 1 if the cooling schedule satisfies the logarithmic decay condition:
where $c$ is a constant greater than the maximum depth of any local energy barrier. While logarithmic cooling is slow, modern practical schedules deploy geometric cooling ($T_{t+1} = \alpha T_t$ with $\alpha \in [0.85, 0.98]$) to find near-optimal parameters across rugged likelihood landscapes.
Trust-Region Methods and the Powell Dogleg Step
In unconstrained optimization, line-search methods first choose a direction $\mathbf{p}_k$ and then search for an appropriate step size $\alpha_k$. In contrast, Trust-Region Methods first determine a maximum step radius $\Delta_k > 0$, construct a local quadratic model:
and solve the constrained sub-problem strictly inside the "trust region":
The Powell Dogleg Step:
To solve the trust-region sub-problem efficiently without computing exact constrained quadratics, M. J. D. Powell formulated the Dogleg Step. The dogleg trajectory connects three points:
- The origin $\mathbf{p} = \mathbf{0}$.
- The Cauchy Point $\mathbf{p}_C$: The unconstrained minimum of the quadratic model along the steepest descent direction:
- The Newton Point $\mathbf{p}_N = -\mathbf{B}_k^{-1} \mathbf{g}_k$.
The dogleg algorithm moves along the piecewise linear path from $\mathbf{0} \to \mathbf{p}_C \to \mathbf{p}_N$, intersecting the spherical trust-region boundary $\|\mathbf{p}\|_2 = \Delta_k$.
- If the quadratic model accurately predicts the true function decrease ($\rho_k = \frac{f(\boldsymbol{\theta}_k) - f(\boldsymbol{\theta}_k + \mathbf{p}_k)}{m_k(\mathbf{0}) - m_k(\mathbf{p}_k)} \approx 1$), the trust region is expanded: $\Delta_{k+1} = 2 \Delta_k$.
- If the model is inaccurate ($\rho_k < 0.25$), the step is rejected and the trust region is shrunk: $\Delta_{k+1} = 0.5 \Delta_k$.
Trust-region methods provide unconditional global convergence guarantees even for highly non-convex, ill-conditioned statistical likelihood surfaces.
§7.11 Profile Likelihoods and the Backfitting Algorithm in Additive Modeling
In semiparametric statistics and high-dimensional regression, optimization criteria often partition naturally into primary parameters of scientific interest $\boldsymbol{\theta} \in \mathbb{R}^p$ (e.g. treatment effect) and high-dimensional nuisance parameters $\boldsymbol{\eta} \in \mathbb{R}^q$ (e.g. baseline hazards, non-parametric smoothers, or nuisance intercepts).
The Profile Likelihood Method
Let $\ell(\boldsymbol{\theta}, \boldsymbol{\eta})$ be the joint log-likelihood. To eliminate the $q$ nuisance parameters without integrating them out (as in Bayesian marginalization), classical likelihood theory defines the Profile Log-Likelihood:
where $\hat{\boldsymbol{\eta}}(\boldsymbol{\theta}) = \arg\max_{\boldsymbol{\eta}} \ell(\boldsymbol{\theta}, \boldsymbol{\eta})$ is the restricted maximum likelihood estimate of the nuisance parameters for any fixed $\boldsymbol{\theta}$.
Theoretical Properties of the Profile Likelihood:
1. Identical Point Estimates: The global maximum of the profile likelihood matches the joint MLE:
2. Profile Score Function: By the chain rule:
Because $\hat{\boldsymbol{\eta}}$ maximizes $\ell$ with respect to $\boldsymbol{\eta}$, the stationary condition requires $\left. \frac{\partial \ell}{\partial \boldsymbol{\eta}} \right|_{\boldsymbol{\eta} = \hat{\boldsymbol{\eta}}} = \mathbf{0}$. The second term vanishes! The profile score is simply the ordinary score evaluated at the constrained MLE:
3. Profile Likelihood Confidence Intervals:
Inverting the likelihood ratio test on the profile curve produces Wilks confidence intervals:
These profile intervals properly reflect the statistical uncertainty of estimating the nuisance parameters $\boldsymbol{\eta}$, providing far superior coverage over standard Wald intervals when nuisance parameters are non-linearly constrained.
The Backfitting Algorithm for Generalized Additive Models
In Generalized Additive Models (GAMs), the additive predictor is a sum of $p$ smooth univariate functions:
where each $f_j$ is an unknown smooth curve constrained to have zero mean ($\sum_{i=1}^n f_j(x_{ij}) = 0$). Fitting all $p$ functions simultaneously via a single high-dimensional spline matrix can be memory-intensive.
Trevor Hastie and Robert Tibshirani (1990) formulated the Backfitting Algorithm, which decouples the multivariate problem into a sequence of simple 1D smoothing operations.
Algorithmic Recurrence:
- Initialize $\alpha = \frac{1}{n} \sum y_i$, and $f_1^{(0)} = f_2^{(0)} = \dots = f_p^{(0)} = \mathbf{0}$.
- In a cyclic loop $j = 1, 2, \dots, p$:
- Form the partial residual vector by subtracting the current fitted effects of all other $p - 1$ predictors:
- Apply a univariate smoother $\mathcal{S}_j$ (such as LOESS, smoothing spline, or local linear regression) to predict the partial residual from predictor $X_j$:
- Center the updated curve: $\mathbf{f}_j \leftarrow \mathbf{f}_j - \text{mean}(\mathbf{f}_j)$.
- Repeat step 2 until the relative change in all function estimates falls below convergence threshold $\epsilon$.
Gauss–Seidel Convergence:
Hastie and Tibshirani proved that if the individual smoothers $\mathcal{S}_j$ are linear operators ($\mathbf{f}_j = \mathbf{S}_j \mathbf{r}_j$) and self-adjoint (symmetric) with eigenvalues bounded in $[0, 1]$, the Backfitting algorithm is mathematically equivalent to the Gauss–Seidel iterative solver for the linear operator equation $(\mathbf{I} - \mathbf{M}) \mathbf{f} = \mathbf{d}$, guaranteeing global convergence to a unique stationary smooth surface.
§7.12 Automatic Differentiation (AutoDiff): Forward Mode, Reverse Mode, and Modern Computational Graphs
In modern statistical computing—such as fitting non-linear mixed models, deep neural networks, Hamiltonian Monte Carlo (HMC/NUTS), and variational inference—optimization algorithms require exact gradients $\nabla f(\boldsymbol{\theta})$ and Hessians $\nabla^2 f(\boldsymbol{\theta})$.
Historically, statisticians relied on two flawed approaches:
- Numerical Differentiation (Finite Differences):
Suffers from truncation error when $h$ is large, and catastrophic floating-point cancellation when $h$ is small. Furthermore, computing a gradient for $p$ parameters requires $p + 1$ function evaluations, making it hopelessly slow for high-dimensional models.
- Symbolic Differentiation: Computes exact algebraic formulas via computer algebra systems (Mathematica, SymPy), but suffers from expression swell, producing exponentially complex equations that choke compilers.
The modern solution that powers PyTorch, JAX, Stan, and TensorFlow is Automatic Differentiation (AutoDiff). AutoDiff evaluates exact mathematical derivatives to machine precision by decomposing computer programs into elementary arithmetic operations and applying the chain rule algorithmically.
Forward-Mode AutoDiff and Dual Numbers
Forward-mode AutoDiff evaluates derivatives simultaneously alongside the primal function evaluation using the algebra of Dual Numbers:
Let $f(x)$ be a function. Evaluating $f$ on a dual number expands via Taylor series:
The real component yields the function value $f(a)$, and the dual component yields the exact derivative $f'(a) b$!
- Multi-Variable Scaling: For a function $f: \mathbb{R}^p \to \mathbb{R}^m$, evaluating the Jacobian requires $p$ forward passes (one per input coordinate).
- Forward-mode is optimal when $p \ll m$ (few inputs, many outputs).
Reverse-Mode AutoDiff (Backpropagation)
When a statistical objective function maps a massive parameter vector $\boldsymbol{\theta} \in \mathbb{R}^p$ to a single scalar loss or log-likelihood value $\ell: \mathbb{R}^p \to \mathbb{R}$ (so $m = 1$ and $p \gg 1$, typical in regression, neural nets, and Bayesian posteriors), Reverse-Mode AutoDiff is vastly superior.
The Two-Pass Execution Mechanics:
1. The Forward Pass (Tape Recording):
The computer evaluates the objective function from input parameters to the terminal scalar output. Every elementary operation ($+, -, \times, \div, \exp, \sin$) is recorded on an internal directed acyclic execution graph (the Wengert List or Tape), caching intermediate values.
2. The Reverse Pass (Adjoint Propagation):
The algorithm initializes the adjoint of the terminal scalar output:
It then sweeps backward through the recorded tape in reverse topological order, applying the chain rule locally:
The Fundamental Complexity Theorem:
The total computational cost of computing the entire $p$-dimensional gradient vector $\nabla \ell(\boldsymbol{\theta})$ via Reverse-Mode AutoDiff is at most 3 to 4 times the cost of evaluating the scalar function $\ell(\boldsymbol{\theta})$ once, completely independent of parameter dimension $p$!
This extraordinary algorithmic efficiency explains why modern probabilistic systems (Stan, PyMC, Pyro) can execute Hamiltonian Monte Carlo trajectories and variational optimizations across models with millions of parameters in seconds.
§7.13 Coordinate Descent, Proximal Gradients, and High-Dimensional Sparse Regression
In contemporary genomic, econometric, and biostatistical modeling, researchers frequently confront high-dimensional regression regimes where the number of candidate covariates $p$ vastly exceeds the available sample size $n$ ($p \gg n$). In such ill-posed settings, the ordinary least squares Gram matrix $\mathbf{X}^T \mathbf{X} \in \mathbb{R}^{p \times p}$ has rank at most $n$, making it singular and non-invertible. To perform consistent parameter estimation and feature selection simultaneously, statisticians introduce sparsity-inducing penalties.
The Lasso and Elastic Net Regularization Objectives
The Least Absolute Shrinkage and Selection Operator (Lasso) (Tibshirani, 1996) regularizes the residual sum of squares by the $\ell_1$ norm of the parameter vector:
where $\lambda \ge 0$ is a tuning parameter controlling the degree of sparsity. When collinearity among predictors is severe, the Elastic Net (Zou & Hastie, 2005) combines $\ell_1$ and $\ell_2$ penalties:
with mixing parameter $\alpha \in [0, 1]$. Because the $\ell_1$ norm $|\beta_j|$ has a sharp non-differentiable singularity (kink) at $\beta_j = 0$, classical smooth gradient descent and Newton–Raphson algorithms cannot be applied directly.
Cyclic Coordinate Descent and the Soft-Thresholding Operator
Friedman, Hastie, and Tibshirani (2007, 2010) demonstrated that Cyclic Coordinate Descent provides an astonishingly fast, numerically stable solver for Lasso and Elastic Net problems (implemented in the celebrated `glmnet` R package and `scikit-learn`'s `Lasso` and `ElasticNet`).
Suppose all predictors are standardized so that $\frac{1}{n} \sum_{i=1}^n X_{ij}^2 = 1$. When optimizing with respect to a single coordinate $\beta_j$ while holding all other $p - 1$ coefficients $\boldsymbol{\beta}_{-j}$ fixed, the partial residual vector is:
The univariate objective for coordinate $j$ reduces to:
Let $z_j = \frac{1}{n} \mathbf{x}_j^T \mathbf{r}_{-j}$ represent the simple OLS regression coefficient of the partial residuals on feature $j$. The global unconstrained minimizer of $g(\beta_j)$ is given in closed form by the Soft-Thresholding Operator $\mathcal{S}_\lambda(z)$:
The coordinate descent algorithm repeatedly cycles through coordinates $j = 1, 2, \dots, p$:
- Compute partial correlation $z_j = \frac{1}{n} \mathbf{x}_j^T \mathbf{r} + \beta_j$.
- Update $\beta_j \leftarrow \mathcal{S}_\lambda(z_j)$.
- Update residual vector $\mathbf{r} \leftarrow \mathbf{r} - \mathbf{x}_j (\beta_j^{\text{new}} - \beta_j^{\text{old}})$.
Each univariate scalar step requires only $\mathcal{O}(n)$ operations! Because the objective function decomposes into a smooth convex loss plus a separable non-smooth penalty $\sum g_j(\beta_j)$, Tseng (2001) proved that coordinate descent is guaranteed to converge to the exact global minimum.
Active-Set Convergence and Pathwise Warm Starts
In production statistical software, coordinate descent achieves supercomputer-level efficiency through two algorithmic innovations:
1. Warm Starts along a Regularization Path: Models are solved over a descending grid of $K \approx 100$ penalty values $\lambda_{\max} > \lambda_1 > \dots > \lambda_K$. At $\lambda_{\max} = \max_j \frac{1}{n} |\mathbf{x}_j^T \mathbf{y}|$, all coefficients are identically zero ($\boldsymbol{\beta} = \mathbf{0}$). For each subsequent $\lambda_k$, the algorithm initializes search from the optimal solution $\hat{\boldsymbol{\beta}}(\lambda_{k-1})$ of the preceding problem, requiring only a handful of coordinate cycles to reach machine precision.
2. Active-Set Strategies: The algorithm maintains an active set $\mathcal{A} = \{j : \beta_j \ne 0\}$. Coordinate descent iterates exclusively over features in $\mathcal{A}$ until convergence. A single full cycle across all $p$ features is then executed to verify optimality via Karush–Kuhn–Tucker (KKT) conditions ($|z_k| \le \lambda$ for all $k \notin \mathcal{A}$). If any feature violates KKT, it is appended to $\mathcal{A}$ and active cycling resumes. In regimes where $p = 100,000$ and only $50$ features are active, this reduces computational effort by more than $99.9\%$.
Step-by-Step Statistical Computing Solutions
Three original questions connect calculations, definitions and interpretation. Open each solution to follow the reasoning.
In epidemiological research, an investigator fits a binary logistic regression model predicting myocardial infarction:
where the success probability $p_i = \mathbb{P}(Y_i = 1 \mid \mathbf{x}_i)$ is linked to a linear predictor $\eta_i = \mathbf{x}_i^\top \boldsymbol{\beta}$ via the canonical logit link:
- Formulate the total log-likelihood function $\ell(\boldsymbol{\beta})$ of the sample.
- Derive the exact gradient vector (score vector) $\mathbf{g}(\boldsymbol{\beta}) = \nabla \ell(\boldsymbol{\beta})$ and the observed Hessian matrix $\mathbf{H}(\boldsymbol{\beta}) = \nabla^2 \ell(\boldsymbol{\beta})$.
- Derive the Expected (Fisher) Information Matrix $\mathcal{I}(\boldsymbol{\beta}) = \mathbb{E}[-\mathbf{H}(\boldsymbol{\beta})]$ and prove that $\mathbf{H}(\boldsymbol{\beta})$ is strictly non-stochastic, establishing exact mathematical equivalence between Newton–Raphson and Fisher Scoring.
- Formulate the Iteratively Reweighted Least Squares (IRLS) representation, defining the working diagonal weight matrix $\mathbf{W}$ and adjusted working response vector $\mathbf{z}$.
- Given a toy dataset of $n = 3$ subjects with single predictor $x$:
Starting from initial guess $\beta^{(0)} = 0.0$, compute the first iteration values:
- Predicted probabilities $p_i^{(0)}$
- Working weights $W_i^{(0)}$
- Working responses $z_i^{(0)}$
- Updated parameter estimate $\beta^{(1)}$ to four decimal places.
Solution, step 1: Formulate the logistic regression log-likelihood.
For a binary Bernoulli observation $y_i \in \{0, 1\}$:
The log-likelihood for observation $i$ is:
Substitute the logit link $\ln(p_i / (1 - p_i)) = \mathbf{x}_i^\top \boldsymbol{\beta}$ and $1 - p_i = \frac{1}{1 + e^{\mathbf{x}_i^\top \boldsymbol{\beta}}}$:
Summing across all $n$ independent observations:
Solution, step 2: Derive score vector and observed Hessian matrix.
1. Gradient (Score Vector):
Differentiate $\ell(\boldsymbol{\beta})$ with respect to $\beta_j$:
Since $p_i = \frac{e^{\mathbf{x}_i^\top \boldsymbol{\beta}}}{1 + e^{\mathbf{x}_i^\top \boldsymbol{\beta}}}$:
In compact matrix notation:
where $\mathbf{p} = (p_1, \dots, p_n)^\top$.
2. Hessian Matrix:
Differentiate $\frac{\partial \ell}{\partial \beta_j}$ with respect to $\beta_k$:
Using the quotient rule on $p_i = \frac{1}{1 + e^{-\mathbf{x}_i^\top \boldsymbol{\beta}}}$:
Therefore:
In matrix notation, let $\mathbf{W} \in \mathbb{R}^{n \times n}$ be the diagonal matrix of binomial variances:
The Hessian matrix is:
Solution, step 3: Expected information and equivalence of Newton–Raphson and Fisher Scoring.
Notice that the Hessian matrix:
depends on the parameters $\boldsymbol{\beta}$ and explanatory variables $\mathbf{X}$, but does not depend on the random observations $\mathbf{y}$!
Therefore, taking the expectation over $\mathbf{y}$:
Because $\mathcal{J}(\boldsymbol{\beta}) \equiv \mathcal{I}(\boldsymbol{\beta})$, the Newton–Raphson algorithm and the Fisher Scoring algorithm are mathematically and numerically identical:
Solution, step 4: IRLS formulation.
Rewrite the update step by factoring out $(\mathbf{X}^\top \mathbf{W}_t \mathbf{X})^{-1} \mathbf{X}^\top \mathbf{W}_t$:
Define the working response vector $\mathbf{z}_t$:
In scalar components, for observation $i$:
The update is computed as a standard Weighted Least Squares regression:
Solution, step 5: Numerical iteration 1 computation.
We are given:
- $\mathbf{y} = [1, \, 0, \, 1]^\top$
- $\mathbf{x} = [0.5, \, -1.0, \, 1.5]^\top$
- Initial parameter: $\beta^{(0)} = 0.0$.
1. Linear Predictors and Probabilities at Step 0:
2. Working Weights $W_i^{(0)}$:
3. Working Responses $z_i^{(0)}$:
Using $z_i^{(0)} = \eta_i^{(0)} + \frac{y_i - p_i^{(0)}}{W_i^{(0)}} = 0.0 + \frac{y_i - 0.50}{0.25} = 4(y_i - 0.50)$:
- For $i = 1$ ($y_1 = 1$): $z_1^{(0)} = 4(1 - 0.5) = 4(0.5) = \mathbf{2.0}$
- For $i = 2$ ($y_2 = 0$): $z_2^{(0)} = 4(0 - 0.5) = 4(-0.5) = \mathbf{-2.0}$
- For $i = 3$ ($y_3 = 1$): $z_3^{(0)} = 4(1 - 0.5) = 4(0.5) = \mathbf{2.0}$
4. Updated Parameter Estimate $\beta^{(1)}$:
In our 1-parameter model:
Now evaluate $\mathbf{X}^\top \mathbf{W}_0 \mathbf{z}_0$:
Therefore:
In a single IRLS step, the parameter estimate updates from $0.0$ to $\beta^{(1)} \approx 1.7143$.
The Expectation–Maximization (EM) algorithm is deployed to estimate parameter vector $\boldsymbol{\theta}$ in a latent variable model with observed data $\mathbf{Y}$ and unobserved latent variables $\mathbf{Z}$.
Let $p(\mathbf{Y}, \mathbf{Z} \mid \boldsymbol{\theta})$ be the complete-data joint probability density function. The observed data log-likelihood is:
The EM algorithm constructs the $Q$-function:
and updates the parameter via:
- Define the Kullback–Leibler (KL) divergence between two probability distributions $q(\mathbf{z})$ and $p(\mathbf{z})$:
Using Jensen's inequality for convex functions, prove Gibbs' Inequality: $\mathcal{D}_{KL}(q \,\|\, p) \ge 0$, with equality if and only if $q(\mathbf{z}) = p(\mathbf{z})$ almost everywhere.
- For any arbitrary probability distribution $q(\mathbf{z})$ over the latent space, prove that the observed log-likelihood admits the exact variational decomposition:
where $\mathcal{L}(q, \boldsymbol{\theta}) = \int q(\mathbf{z}) \ln\left( \frac{p(\mathbf{Y}, \mathbf{z} \mid \boldsymbol{\theta})}{q(\mathbf{z})} \right) d\mathbf{z}$ is the Evidence Lower Bound (ELBO).
- Using the ELBO decomposition, demonstrate what occurs during the E-step when $q(\mathbf{z})$ is set to $p(\mathbf{z} \mid \mathbf{Y}, \boldsymbol{\theta}^{(t)})$.
- Prove that $\ell(\boldsymbol{\theta}^{(t+1)}) \ge \ell(\boldsymbol{\theta}^{(t)})$, establishing monotonic non-decreasing convergence.
Solution, step 1: Proof of Gibbs' Inequality via Jensen's Inequality.
The Kullback–Leibler divergence is:
Recall that the negative logarithm $-\ln(t)$ is a strictly convex function on $(0, \infty)$ (since its second derivative $\frac{d^2}{dt^2}(-\ln t) = \frac{1}{t^2} > 0$).
By Jensen's Inequality, for any strictly convex function $\phi$ and random variable $X$:
Applying this with $\phi(t) = -\ln(t)$ and $X = \frac{p(\mathbf{Z})}{q(\mathbf{Z})}$:
Evaluate the inner expectation:
Substitute this back:
Furthermore, because $-\ln(t)$ is strictly convex, equality holds if and only if $X = \frac{p(\mathbf{Z})}{q(\mathbf{Z})}$ is constant with probability 1. Since both $p$ and $q$ integrate to 1, this constant must be 1, meaning $q(\mathbf{z}) = p(\mathbf{z})$ almost everywhere.
This proves Gibbs' Inequality:
Solution, step 2: Variational decomposition of the log-likelihood (ELBO).
Let $q(\mathbf{z})$ be an arbitrary probability density function on the latent space $\mathcal{Z}$ satisfying $\int q(\mathbf{z}) d\mathbf{z} = 1$.
Start from the observed log-likelihood $\ell(\boldsymbol{\theta}) = \ln p(\mathbf{Y} \mid \boldsymbol{\theta})$:
By Bayes' rule:
Multiply top and bottom by $q(\mathbf{z})$:
Take the logarithm:
Integrate with respect to $q(\mathbf{z}) d\mathbf{z}$:
Recognize the two terms:
- The first term is the Evidence Lower Bound (ELBO) $\mathcal{L}(q, \boldsymbol{\theta})$:
- The second term is the Kullback–Leibler divergence $\mathcal{D}_{KL}(q(\mathbf{Z}) \,\|\, p(\mathbf{Z} \mid \mathbf{Y}, \boldsymbol{\theta}))$.
Therefore:
Because $\mathcal{D}_{KL} \ge 0$, this establishes that $\mathcal{L}(q, \boldsymbol{\theta})$ is a strict lower bound on the log-likelihood:
Solution, step 3: Action of the E-step.
In the E-step, the parameter is fixed at its current value $\boldsymbol{\theta}^{(t)}$. We maximize the lower bound $\mathcal{L}(q, \boldsymbol{\theta}^{(t)})$ with respect to the distribution $q$:
By Gibbs' Inequality, the KL divergence attains its absolute minimum of zero if and only if:
When $q$ is set to the exact posterior of the latent variables:
The lower bound becomes tangent to the true log-likelihood curve at $\boldsymbol{\theta}^{(t)}$!
Furthermore, evaluate $\mathcal{L}(q^*, \boldsymbol{\theta})$:
Since the entropy of $q^*$ does not depend on $\boldsymbol{\theta}$, maximizing $\mathcal{L}(q^*, \boldsymbol{\theta})$ with respect to $\boldsymbol{\theta}$ is identical to maximizing the $Q$-function!
Solution, step 4: Complete proof of monotonic ascent.
Now evaluate the progression across the two steps:
1. E-step Tangency:
2. M-step Maximization:
The M-step updates $\boldsymbol{\theta}^{(t+1)} = \arg\max_{\boldsymbol{\theta}} Q(\boldsymbol{\theta} \mid \boldsymbol{\theta}^{(t)}) = \arg\max_{\boldsymbol{\theta}} \mathcal{L}(q^*, \boldsymbol{\theta})$. Therefore:
3. Lower Bound Property:
By the variational decomposition, for any $\boldsymbol{\theta}$, including $\boldsymbol{\theta}^{(t+1)}$:
Since $\mathcal{D}_{KL} \ge 0$:
Chaining the inequalities together:
Therefore:
This completes the mathematical proof that the observed log-likelihood monotonically increases at every iteration of the EM algorithm.
An environmental engineer models rainfall depth $Y_i > 0$ using a Gamma Generalized Linear Model with a reciprocal link function (the canonical link):
The probability density function of $Y \sim \text{Gamma}(\mu, \nu)$ is:
where $\nu > 0$ is the known shape parameter.
- Show that the Gamma distribution belongs to the exponential dispersion family, and identify the natural parameter $\theta$, cumulant function $b(\theta)$, and variance function $V(\mu)$.
- Derive the log-likelihood function $\ell(\boldsymbol{\beta})$, the score vector $\mathbf{g}(\boldsymbol{\beta})$, and the observed Hessian matrix $\mathbf{H}(\boldsymbol{\beta})$.
- Derive the Expected (Fisher) Information Matrix $\mathcal{I}(\boldsymbol{\beta})$ and prove whether Newton–Raphson and Fisher Scoring are identical for this canonical Gamma GLM.
- An empirical calibration collects $n = 3$ precipitation observations:
Under model $\frac{1}{\mu_i} = \beta x_i$, starting from initial estimate $\beta^{(0)} = 0.50$:
- Compute the fitted means $\mu_i^{(0)}$
- Compute the score value $g(\beta^{(0)})$
- Compute the information value $\mathcal{I}(\beta^{(0)})$
- Calculate the updated parameter $\beta^{(1)}$ to four decimal places.
Solution, step 1: Exponential dispersion formulation of the Gamma distribution.
Rewrite the density $f(y \mid \mu, \nu)$:
Multiply and divide by $\nu = 1/\phi$ (where dispersion $\phi = 1/\nu$):
This matches the canonical exponential dispersion family format:
where:
1. Natural Parameter:
2. Cumulant Generator Function:
3. Dispersion Parameter:
4. Mean and Variance Functions:
Therefore, the variance function is:
Solution, step 2: Log-likelihood, score vector, and observed Hessian.
With canonical link $\eta_i = \frac{1}{\mu_i} = \mathbf{x}_i^\top \boldsymbol{\beta}$, the natural parameter is:
1. Log-Likelihood Function:
2. Score Vector (Gradient):
Differentiate with respect to $\beta_j$:
Since $\mu_i = \frac{1}{\mathbf{x}_i^\top \boldsymbol{\beta}}$:
In matrix notation:
3. Observed Hessian Matrix:
Differentiate $\frac{\partial \ell}{\partial \beta_j}$ with respect to $\beta_k$:
Since $\mu_i = (\mathbf{x}_i^\top \boldsymbol{\beta})^{-1}$:
Therefore:
In matrix notation:
Solution, step 3: Expected information and equivalence proof.
Notice that the Hessian matrix:
depends solely on the model means $\mu_i = 1 / (\mathbf{x}_i^\top \boldsymbol{\beta})$ and covariates $\mathbf{X}$. It is completely independent of the random realizations $y_i$!
Therefore:
Because $\mathcal{J}(\boldsymbol{\beta}) \equiv \mathcal{I}(\boldsymbol{\beta})$, the Newton–Raphson algorithm and the Fisher Scoring algorithm are strictly mathematically identical for this canonical Gamma GLM!
Solution, step 4: Numerical computation of update step 1.
We are given:
- $\nu = 1.0$
- $\mathbf{y} = [0.8, \, 1.2, \, 2.0]^\top$
- $\mathbf{x} = [1.0, \, 2.0, \, 3.0]^\top$
- Model: $\frac{1}{\mu_i} = \beta x_i$
- Initial parameter: $\beta^{(0)} = 0.50$.
1. Calculate Fitted Means at Step 0:
- For $i = 1$ ($x_1 = 1.0$): $\mu_1^{(0)} = \frac{2.0}{1.0} = \mathbf{2.0}$
- For $i = 2$ ($x_2 = 2.0$): $\mu_2^{(0)} = \frac{2.0}{2.0} = \mathbf{1.0}$
- For $i = 3$ ($x_3 = 3.0$): $\mu_3^{(0)} = \frac{2.0}{3.0} \approx \mathbf{0.666667}$
2. Calculate the Score Function $g(\beta^{(0)})$:
Compute each observation's contribution:
- $i = 1$: $x_1 (\mu_1 - y_1) = 1.0 \times (2.0 - 0.8) = 1.0 \times 1.2 = \mathbf{1.20}$
- $i = 2$: $x_2 (\mu_2 - y_2) = 2.0 \times (1.0 - 1.2) = 2.0 \times (-0.2) = \mathbf{-0.40}$
- $i = 3$: $x_3 (\mu_3 - y_3) = 3.0 \times (0.666667 - 2.0) = 3.0 \times (-1.333333) = \mathbf{-4.00}$
Summing across all 3 observations:
3. Calculate Fisher Information $\mathcal{I}(\beta^{(0)})$:
Notice that $x_i \mu_i = x_i \left( \frac{1}{\beta x_i} \right) = \frac{1}{\beta} = \frac{1}{0.50} = 2.0$ for all observations!
Summing across all 3 observations:
4. Compute the Updated Parameter $\beta^{(1)}$:
The Fisher scoring update step is:
The parameter estimate updates from $\beta^{(0)} = 0.5000$ to $\beta^{(1)} \approx 0.2333$ in a single iteration.