design matrix, surface plus level coefficients, and quadratic prior precision matrix
Quadrature and dispersion equation
Q
Krawtchouk count quadrature order for ni>128 (6 for surface moments, 8 for dispersion moments)
dj,ej
diagonal and off-diagonal entries of the Q×Q symmetric tridiagonal Krawtchouk Jacobi matrix
σz,i2,qi
unfitted second moment E[r~i2] and first-order refit-corrected expectation qi
ℓi,Si
surface leverage xi⊤J−1xi and sandwich variance xi⊤J−1ΩJ−1xi
bη,i,wi
shrinkage bias xi⊤J−1Pθ and variance-equation weight (∂σz,i2/∂v)/Var(r~i2)
Context. Agency mortgage pools share two traits that break standard logistic regression. First, pools at the same loan age and coupon still differ persistently in unobserved borrower and servicer mix, producing strong binomial overdispersion. Second, pool sizes span four orders of magnitude, from 25 loans up to roughly 105 loans in giant multi-issuer pools. Plain binomial maximum likelihood lets a handful of huge pools dominate both fitting and evaluation, while naive random-effects approximations attenuate the surface or bias average predicted rates upward.
Decision meshes resolve both problems with two linked devices. A mean-neutral location shift A(ηi,v) keeps average termination rates separate from pool dispersion, and a centered conditional-mode estimating equation removes penalized quasi-likelihood (PQL) bias while capping every pool's effective information near 1/v. The interactive explorer and detailed walkthrough show overdispersed coin flips visually. This note derives the exact equations, the Krawtchouk quadrature rule for large ni, and the refit-corrected dispersion equation for v.
Setting. Pool i has ninumber of loans at risk in pool i during the observation month loans at risk and kiobserved number of loan terminations in pool i (random count Ki) loan terminations. The model targets loan-count termination probability (distinct from balance-weighted SMM) through a Gaussian pool random effect Uiunobserved pool-level logit shock Ui∼N(0,v) capturing persistent overdispersion with common variance vpool random-effect variance on the logit scale, shared across pools in the cross-section:Ki∣UiπiUi∼Binomial(ni,πi),=logistic(Ai+Ui),∼N(0,v).Here logistic(u)=(1+e−u)−1. The location Aimean-neutral logit offset A(ηi,v) chosen so averaging logistic(Ai+Ui) over Ui recovers logistic(ηi)=A(ηi,v) is defined implicitly from the surface's marginal-mean logit ηimarginal-mean logit ηi=offseti+f(xi)+agi, giving predicted probability pi=logistic(ηi) for a new pool (with pi=logistic(ηi)) byEU[logistic(Ai+Ui)]=logistic(ηi).
Step 1
Why mean-neutral centering removes Jensen's-inequality bias. At monthly prepayment rates around p∈[0.01,0.03], the logistic map sits deep in its convex tail (logistic′′(u)=p(1−p)(1−2p)>0). Adding a zero-mean Gaussian Ui directly to ηi inflates the average termination rate by roughly 21vp via Jensen's inequality. On the logit scale, staying mean-neutral shifts the conditional intercept down to Ai≈ηi−21v. Without this shift, changing the dispersion estimate v drags the surface level up or down and mixes dispersion with mean calibration. With Ai solved numerically by Gauss-Hermite quadrature, a new pool's marginal prediction is simply pi=logistic(ηi). Implicit differentiation of the defining identity yields the location sensitivity directly:Ai′=∂ηi∂Ai=EU[πi(1−πi)]pi(1−pi),where πi=logistic(Ai+Ui).
Step 2
Centered conditional-mode estimating equation and the 1/v cap. Given trial ηi and v, the engine finds each pool's conditional MAP mode u^imaximizer of the conditional log-posterior ki(Ai+u)−nilog(1+eAi+u)−u2/(2v) for pool i by solving the first-order conditionu^i=v[ki−nilogistic(Ai+u^i)].Define the mode residual riconditional-mode residual ri=ki−nilogistic(Ai+u^i), equal to u^i/v for v>0 and reducing to ki−nipi at v=0=ki−nilogistic(Ai+u^i). It equals u^i/v for v>0 and stays well-defined at v=0. In classical PQL, plugging ri directly into a score equation biases the fitted surface toward zero because posterior shrinkage and binomial discreteness give ri a nonzero repeated-sample mean.
The centered-mode estimator removes that PQL attenuation by subtracting the full repeated-sample expectation miexact repeated-sample expectation EU,K[ri(Ki)] averaged over both Ui∼N(0,v) and Ki∣Ui=EU,K[ri(Ki)]. This forms the centered residual r~i=ri−mi and weighted score si=Ai′r~i. With design X, coefficients θ, and prior precision P, the surface solves the penalized estimating equationX⊤s−Pθ=0by damped Newton steps on its exact derivative. Because E[si]=0 at the true surface for every (ni,ηi,v), the estimating equation stays unbiased in finite samples without maximizing an intractable marginal likelihood.
This mode construction automatically caps giant-pool leverage. As ni→∞, the binomial likelihood overwhelms the prior in the mode equation, pinning Ai+u^i→logit(ki/ni) and ri=u^i/v→(logit(ki/ni)−Ai)/v. The pool's residual approaches its noisy logit error divided by v, so its effective Fisher information jiexpected negative score derivative −E[∂si/∂ηi] holding the data-generating ηi fixed, measuring how strongly pool i informs the surface saturates near 1/v instead of growing linearly as nipi(1−pi). A 100,000-loan pool cannot drown out neighboring smaller pools. On February 2020 data across pool sizes from 25 to 105 loans, the ratio of expected information ji to score variance Virepeated-sample variance Var(si)=(Ai′)2E[r~i2] of pool i's centered score stays in [0.990,1.005], within 1% of the Bartlett identity of the exact marginal score.
Step 3
Gauss-Hermite and Krawtchouk quadrature for fast exact moments. Computing mi, Var(r~i), ji, and variance sensitivities requires integrating functions of u^i(Ki) over both Ui and Ki∣Ui. The outer integral over Ui∼N(0,v) uses Gauss-Hermite quadrature whose order adapts to v (base 24 nodes for surface moments, base 32 for dispersion moments). For the inner binomial expectation over Ki∈{0,…,ni}, pools with ni≤128 are enumerated directly, pruning tail probabilities below 10−18 of the row's total weight.
Enumerating 105 counts per Gauss-Hermite node for giant pools would be prohibitively slow. For ni>128, the engine replaces enumeration with Q-point Gaussian quadrature against the discrete Binomial(ni,π) measure, whose orthogonal polynomials are the Krawtchouk polynomialsdiscrete polynomials orthogonal with respect to the Binomial(n,π) probability mass function; their three-term recurrence defines a Q×Q symmetric tridiagonal Jacobi matrix. Surface moments use Q=6 (exact for polynomials in Ki up to degree 11), and dispersion moments use Q=8 (exact up to degree 15). By Golub-Welsch, the quadrature nodes and weights are the eigenvalues and squared first-row eigenvector entries of the Q×Q symmetric tridiagonal Jacobi matrix (j=0,…,Q−1 on the diagonal, j=0,…,Q−2 off-diagonal):djej=niπ+(1−2π)j,=π(1−π)(j+1)(ni−j).The C++ core solves these nodes in 8-wide SIMD via Aberth-Ehrlich root finding and Christoffel-Darboux weights, falling back to implicit QL whenever a lane is extreme or fails to converge. During intermediate Newton steps, rows whose ηi moved less than 0.01 logit reuse linearized cached moments; the final fit certifies every row on exact moments.
Step 4
Refit-corrected dispersion equation for v. The same quadrature supplies each pool's unfitted second moment σz,i2=E[r~i2], the variance of its squared residual Var(r~i2), and its variance sensitivity ∂σz,i2/∂v. Comparing observed r~i2 directly against σz,i2 would underestimate v because fitting θ pulls η^i toward the data, while prior shrinkage leaves a small squared bias in r~i.
Expanding r~i(η^i) to first order around the true surface gives the refit-corrected expected square qifirst-order refit-corrected expectation of r~i2 accounting for leverage, joint-fit sandwich covariance, and squared shrinkage bias. Define penalized information J=P+X⊤diag(j)X and score covariance Ω=X⊤diag((Ai′)2σz,i2)X. With derivative di=ji/Ai′, leverage ℓi=xi⊤J−1xi, sandwich variance Si=xi⊤J−1ΩJ−1xi, and shrinkage bias bη,i=xi⊤J−1Pθ,qi=σz,i2−2jiℓiσz,i2+di2Si+(dibη,i)2,clamped below at zero. The pool variance solves the weighted dispersion equationi∑wi(r~i2−qi)=0,wi=Var(r~i2)∂σz,i2/∂v.Weighting by sensitivity over variance downweights tiny pools that carry almost no information about v. Intermediate mesh-refinement rounds take one bounded variance step with a 1% hold. The final fit runs an alternating secant search certified on 8-node Krawtchouk and base-32 Gauss-Hermite moments, resolving to v=0 if the dispersion score is already nonpositive at v=0.
Terms
Mean-neutral offset
Solve EU[logistic(Ai+Ui)]=logistic(ηi) (Ai≈ηi−21v at low rates) so v does not bias average predicted rates.
Centered mode equation
u^i=v[ki−nilogistic(Ai+u^i)], r~i=ri−E[ri], si=Ai′r~i, solve X⊤s−Pθ=0; zero PQL bias.
Giant-pool leverage cap
As ni→∞, ri=u^i/v so effective information ji flattens near 1/v instead of growing as nipi(1−pi); ji/Vi∈[0.990,1.005].
Krawtchouk quadrature
Exact enumeration for ni≤128; for ni>128, Q-point binomial Gaussian quadrature (Q=6 surface, Q=8 dispersion) from the tridiagonal Jacobi matrix (dj,ej).
Refit-corrected variance
∑iwi(r~i2−qi)=0 with qi=σz,i2−2jiℓiσz,i2+di2Si+(dibη,i)2 and wi=(∂σz,i2/∂v)/Var(r~i2).
Because ∥X∥2 exceeds ∥θ∥2 by about d on average, the best factor is about 1−d/∥X∥2, and the James-Stein version beats the raw observation at every θ once d≥3.
Measuring a weight change by how far it moves a unit-RMS input gives the update −ηdout/dinUV⊤, which, when din≤dout and the gradient has full rank, moves the output of every unit-RMS input by exactly η whatever the width, which is the μP property, here derived from a choice of norm.
A trained linear-attention layer keeps the fraction Nλi/((N+1)λi+trΣ) of the signal in eigendirection i, a ridge-like shrinkage fixed at training time that does not weaken as the prompt grows; and because the layer applies a fixed matrix where least squares would invert the prompt's sample covariance, its error keeps a 1/M term even on noiseless prompts.
The reproduction draws the reward head's weights with standard deviation 1/dmodel+1, shifts the reward so reference summaries score 0 on average, and whitens advantages to mean 0 and variance 1 in each batch, so the signal reaching the policy has a fixed size.