Why Extreme Predictors Matter During Integration
In a generalized linear mixed model, a quadrature rule evaluates the conditional likelihood at a set of random-effect values. Each value can produce a different linear predictor, and some may be far from zero. A direct calculation can then fail even when the likelihood calculation is mathematically well defined: exponentials may overflow, probabilities may round to exactly zero or one, and subtracting nearly equal numbers may erase meaningful digits. These failures can distort an integrated likelihood and, in turn, estimation.
The aim is not to change the model or to force predictors into an arbitrary range. It is to evaluate the same likelihood using algebraically equivalent formulas that behave well in finite-precision arithmetic, and to combine integration terms on the log scale.
Model Contributions and Assumptions
For a binary response, suppose \(Y\in\{0,1\}\) has a Bernoulli distribution conditional on the random effects, with logit link and linear predictor \(\eta\). Thus \(p=P(Y=1\mid\text{random effects})=1/(1+\exp(-\eta))\). For a binomial count, suppose \(Y\in\{0,\ldots,m\}\) is conditionally binomial with size \(m\) and the same logit link. For a Poisson count, suppose \(Y\in\{0,1,\ldots\}\) is conditionally Poisson with log link, so its mean is \(\lambda=\exp(\eta)\). In each case, \(\eta\) includes the fixed-effect, random-effect, and any offset terms specified by the model.
These likelihood contributions assume the stated conditional response distributions and the GLMM’s conditional independence structure: responses are independent given the random effects and model parameters. Numerical integration then averages the conditional likelihood over the specified random-effects distribution. The stable formulas below do not repair a misspecified response distribution, an incorrect random-effects model, or an inaccurate integration rule.
For a binary observation, the conditional log-likelihood contribution can be written without first calculating a probability that may round to zero or one:
The second expression separates the two possible outcomes. If \(y=1\), it evaluates \(-s(-\eta)\); if \(y=0\), it evaluates \(-s(\eta)\). For a binomial observation with size \(m\), include its combinatorial term:
When \(\eta\) is large and positive, calculate \(y\eta-m\,s(\eta)\) as \((y-m)\eta-m\log(1+\exp(-\eta))\). This avoids subtracting two large, nearly equal quantities. For small \(\eta\), the usual softplus expression is generally well behaved; implementation libraries often provide a dedicated stable softplus function.
Poisson Terms and Log-Scale Integration
For a Poisson observation, the log-likelihood contribution is \(\ell(y;\eta)=y\eta-\exp(\eta)-\log\Gamma(y+1)\). The factorial term is evaluated as a log-gamma function, rather than by forming \(y!\). A very negative \(\eta\) makes \(\exp(\eta)\) small; underflow of that exponential to zero has a negligible effect on this term. A very positive \(\eta\) is different: once \(\exp(\eta)\) exceeds the largest representable floating-point number, no algebraic rearrangement can store its finite value. The log-likelihood then is extremely negative, and the corresponding likelihood contribution is effectively zero at ordinary numerical precision. A robust implementation must handle that case deliberately, rather than allow an overflow to create an invalid value.
Integration introduces a second numerical issue. If a quadrature approximation has positive weights \(w_q\) and log-likelihood contributions \(L_q\), its sum has the form \(\sum_q w_q\exp(L_q)\). Directly exponentiating every term can underflow, overflow, or lose the smaller contributions. Define \(A_q=\log(w_q)+L_q\), and let \(M=\max_q A_q\). Then:
Every exponent \(A_q-M\) is nonpositive, so no exponential can overflow. A contribution far below the maximum may underflow to zero in the rescaled sum; when its relative size is below machine precision, this is usually harmless. If all \(A_q\) are negative infinity, however, the maximum-subtraction calculation is undefined. That result calls for investigation: all nodes may have been classified as numerically negligible, or an earlier calculation may have failed.
Worked Calculations
Worked Example: A Binary Observation at a Large Positive Predictor
Suppose a hypothetical quadrature node gives \(\eta=40\), and the observed binary response is \(y=0\). The direct probability calculation \(p=1/(1+\exp(-40))\) may round to exactly 1 in finite precision. Taking \(\log(1-p)\) after that rounding would give negative infinity, even though the exact log-likelihood is finite.
Use the stable binary formula. Because \(y=0\), \(\ell(0;40)=-s(40)\). The stable softplus expression gives \(s(40)=40+\log(1+\exp(-40))\). Since \(\exp(-40)\) is approximately \(4.248\times10^{-18}\), the correction is approximately \(4.248\times10^{-18}\), too small to change 40 at ordinary double precision. Thus \(\ell(0;40)\) is approximately \(-40.000\).
The observation is strongly inconsistent with the high conditional success probability implied by \(\eta=40\), so its likelihood contribution is about \(\exp(-40)\), not exactly zero. The stable log calculation preserves a finite value and avoids taking a logarithm of a rounded probability.
Worked Example: A Binomial Count Near Its Upper Limit
Suppose a hypothetical binomial observation has \(m=20\), \(y=19\), and \(\eta=35\). Its log-likelihood, including the binomial coefficient, is \(\log{20\choose19}+19(35)-20s(35)\). Here \({20\choose19}=20\), so the combinatorial term is \(\log(20)\approx2.9957\).
Because the predictor is large and positive, use \(s(35)=35+\log(1+\exp(-35))\). The small correction is approximately \(6.305\times10^{-16}\), so \(20s(35)\approx700+20(6.305\times10^{-16})\). Reorganize the predictor terms before evaluating: \((y-m)\eta-m\log(1+\exp(-\eta))=(-1)(35)-20(6.305\times10^{-16})\).
The resulting log-likelihood is approximately \(2.9957-35-0.00000000000001261=-32.0043\). The correction is shown to make clear what was computed, although it does not affect the displayed rounded answer. The probability of observing 19 successes under a success probability extremely close to one is small, but it is not zero.
Worked Example: Poisson Nodes and a Stable Quadrature Sum
Consider a hypothetical one-dimensional quadrature calculation for a Poisson observation \(y=0\). Two nodes have equal weights \(w_1=w_2=0.5\) and predictors \(\eta_1=0\) and \(\eta_2=710\). The conditional log-likelihood for \(y=0\) is \(-\exp(\eta)\), because \(\log\Gamma(1)=0\).
At the first node, \(L_1=-\exp(0)=-1\), so \(A_1=\log(0.5)-1\approx-1.6931\). At the second node, \(\exp(710)\) exceeds the range of standard double-precision numbers. Its log-likelihood is so negative that its likelihood contribution is negligible relative to the first node; a guarded implementation can represent that contribution as negative infinity for this calculation. Thus \(A_2=-\infty\).
The log-sum-exp calculation has \(M=-1.6931\), and the rescaled sum is \(\exp(A_1-M)+\exp(A_2-M)=1+0=1\). Therefore the log quadrature sum is \(-1.6931+\log(1)=-1.6931\), corresponding to a sum of approximately \(\exp(-1.6931)=0.1839\). Directly exponentiating the Poisson term at the second node would overflow; the log-scale calculation retains the meaningful contribution from the first node.
This example’s negative-infinity representation is justified by the negligible relative contribution in this particular calculation. It is not a rule to replace every large predictor by a fixed cap. If all nodes are treated this way, or if the supposedly negligible node could affect the result, the calculation needs greater numerical range or a more careful implementation.
Implementation Checks and Failure Modes
Stable identities address arithmetic, but they do not guarantee that an integration calculation is accurate. Check that predictors, weights, and component log-likelihoods are finite where expected; that all quadrature weights used in a logarithm are positive; and that each response is within its permitted support. A non-finite predictor can indicate an upstream problem with parameter values, scaling, or the design matrix, rather than a likelihood-tail issue.
Common warning signs include probabilities printed as exactly zero or one followed by infinite log-likelihoods; an exponential overflow in a Poisson contribution; a binomial calculation that subtracts two large nearly equal terms; and an integrated sum that evaluates to zero because all likelihoods were exponentiated directly. Log-scale formulas address these specific problems. They do not correct quadrature error: changing the arithmetic may produce a reliable evaluation of a poor approximation if the integration rule itself is inadequate.
| Approach | Strength | Limitation |
|---|---|---|
| Direct probability and likelihood arithmetic | Simple to inspect for moderate predictors | Can round probabilities to zero or one, overflow, or underflow |
| Stable component formulas and log-sum-exp | Preserve likelihood calculations across a much wider range | Require careful handling of non-finite values and all-negligible sums |
| Clipping predictors to fixed bounds | May prevent a particular overflow | Changes the evaluated model and can distort likelihoods, especially near the clipped region |
The preferred approach is stable evaluation of the specified likelihood, not arbitrary clipping. For Poisson terms whose exponential cannot be represented, use a numerical routine with appropriate range handling and determine whether the resulting contribution is negligible relative to other integration terms. If the computation routinely encounters such cases, inspect the parameter scale, offsets, and quadrature nodes; rescaling predictors where the model permits it may help. A broader numerical type can extend the representable range, but it does not remove the need to check accuracy.
Common Mistake
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- For \(y=1\) and \(\eta=-30\), write a stable expression for the binary log-likelihood and approximate its value.
- For a binomial observation with \(m=12\), \(y=12\), and \(\eta=25\), show the stable form of the predictor-dependent part of the log-likelihood.
- Why is subtracting the largest log contribution before exponentiating useful in quadrature?
- If all quadrature log contributions are negative infinity, can the log-sum-exp identity be evaluated by subtracting their maximum? What should be checked?
Solutions. (1) The contribution is \(-s(-\eta)=-s(30)\), approximately \(-30.000\); this avoids calculating a success probability that may round to zero. (2) Since \(y=m\), the predictor-dependent part is \((y-m)\eta-m\log(1+\exp(-\eta))=-12\log(1+\exp(-25))\), approximately \(-1.667\times10^{-10}\). The full log-likelihood also includes \(\log{12\choose12}=0\). (3) If \(M\) is the largest log contribution, every exponent \(A_q-M\) is nonpositive, so exponentiation cannot overflow; factoring out \(\exp(M)\) preserves the sum exactly in real arithmetic. (4) No. The maximum is negative infinity, and subtracting it gives an undefined difference. Check for invalid predictors, failed component calculations, and whether all contributions were incorrectly classified as negligible; the model and numerical range may also need review.