Tutorials › Pattern-Mixture and Selection Models › Validating Quadrature Accuracy

Likelihood Inference and Instability · Tutorial 134 of 499

Validating Quadrature Accuracy

Learn a practical validation strategy for distinguishing numerical integration error from genuine likelihood and inferential features.

Advanced 12 min read

What You'll Learn

  • Explain why quadrature accuracy must be checked for the likelihood and for the fitted quantities.
  • Compare approximations as the number of quadrature nodes increases.
  • Use an independent integration rule to check a quadrature calculation.
  • Diagnose when numerical error could alter estimates, intervals, or tests.
  • Separate integration error from optimization error and statistical uncertainty.

Why Quadrature Needs Validation

A selection-model likelihood often contains integrals over a latent variable. Numerical quadrature replaces each integral with a finite weighted sum, so the likelihood being optimized is an approximation to the intended likelihood. A fit can appear to converge while still depending materially on that approximation. Validation asks whether increasing the numerical accuracy changes the likelihood, the estimates, or the inferential conclusions enough to matter.

The earlier material on Numerical Integration in Selection-Model Likelihoods introduced quadrature as a way to approximate these integrals. Here the emphasis is on checking the approximation. A single node count, successful optimizer termination, or a plausible-looking estimate is not evidence by itself that numerical integration is adequate.

Definition: Quadrature accuracy is the closeness of a weighted-sum approximation to the integral it is intended to represent. In likelihood analysis, validating quadrature means checking whether integration error is small enough for the likelihood calculations and the estimates or inferential results derived from them.

For illustration, suppose the contribution of subject \(i\) to an observed-data likelihood involves a latent standard-normal variable \(Z\). Write that contribution as \(I_i(\theta)=\int g_i(z;\theta)\phi(z)\,dz\), where \(\theta\) is the model parameter vector, \(g_i\) is the relevant observed-data contribution conditional on \(Z=z\), and \(\phi\) is the standard normal density. The log likelihood is \(\ell(\theta)=\sum_{i=1}^n \log I_i(\theta)\). A quadrature rule with \(K\) nodes approximates each integral and therefore defines an approximate log likelihood, \(\ell_K(\theta)\). The fitted estimate is the maximizer of that approximate function.

$$ I_i(\theta) \approx \sum_{j=1}^{K} w_j g_i(z_j;\theta), \qquad \ell_K(\theta)=\sum_{i=1}^{n}\log\left\{\sum_{j=1}^{K}w_jg_i(z_j;\theta)\right\}. $$

For a standard-normal expectation, the nodes and weights are scaled so that the weighted sum approximates integration against \(\phi\), with the weights summing to one. If the latent variable has a different normal mean or variance, the transformation to the quadrature scale must reflect that distribution. A validation comparison is meaningful only when the likelihood, data, parameter constraints, and other model settings are held fixed while the integration calculation is changed.

What Should Be Compared?

The most direct check is to refit the model using a sequence of increasing node counts. Record more than the final log likelihood: compare parameter estimates, relevant standard errors or profile-likelihood results, and the quantities used in the scientific conclusion. Quadrature approximations need not change monotonically with \(K\), so a small difference at one step is not enough to establish stability. Several successive comparisons are more informative.

A second check uses a different integration rule, such as adaptive integration, at the same fitted parameter values or in a separate refit. Agreement between methods that have different numerical error patterns is useful corroboration. It is not a proof of exactness: two calculations can share a misspecification or a common implementation error. In either comparison, use unrounded output for calculations and report enough digits to make the comparison interpretable.

The relevant tolerance depends on the analysis. A tiny change in the log likelihood can be important when a profile is flat, a constraint is near a decision boundary, or an interval endpoint moves appreciably. Conversely, a change in the last displayed digit may have no practical consequence if estimates and inferential conclusions are unchanged. Numerical tolerances should be judged against the intended use, not selected as universal constants.

Why Small Integration Errors Can Matter

A short approximation explains why checking only the integral values can be misleading. Suppose a quadrature calculation gives \(I_i+\delta_i\) instead of \(I_i\), with \(|\delta_i/I_i|\) small and \(I_i>0\). A first-order expansion of the logarithm gives \(\log(I_i+\delta_i)=\log I_i+\delta_i/I_i+O((\delta_i/I_i)^2)\). Thus the approximate log likelihood can accumulate small relative integration errors across subjects. Moreover, if the likelihood is flat in some parameter direction, a small numerical perturbation can move the maximizer noticeably.

$$ \ell_K(\theta)-\ell(\theta) \approx \sum_{i=1}^{n}\frac{\delta_i(\theta)}{I_i(\theta)}. $$

The effect on an estimate can also be seen from the score equation. Let \(\widehat{\theta}\) maximize the exact log likelihood locally, and suppose the numerical score differs from the exact score there by \(e\). If the Hessian \(H\) is nonsingular and the perturbation is small, a first-order expansion of the numerical score around \(\widehat{\theta}\) yields \(0\approx H\Delta\theta+e\), so \(\Delta\theta\approx-H^{-1}e\). When curvature is weak, \(H^{-1}\) can be large. This is why likelihood ridges and weak identification make careful numerical validation especially important.

Worked Example: Checking Log-Likelihood Stability Across Node Counts

Consider a hypothetical selection-model fit using the same data and optimizer settings at each node count. The maximized approximate log likelihoods are shown below. Define each successive change as the value at the new node count minus the value at the preceding node count.

Nodes \(K\)Maximized approximate log likelihoodChange from preceding fit
15-203.82040—
31-203.814080.00632
63-203.81411-0.00003
127-203.814100.00001
255-203.814100.00000

For 15 to 31 nodes, the change is \(-203.81408-(-203.82040)=0.00632\). For 31 to 63 nodes, it is \(-203.81411-(-203.81408)=-0.00003\), not \(0.00003\). For 63 to 127 nodes, it is \(-203.81410-(-203.81411)=0.00001\). The signs show that these approximations do not move monotonically toward a limit.

The last two changes are small at the displayed precision, but this table alone does not establish adequate quadrature. It reports rounded log likelihoods, not the stability of the fitted parameters or profile calculations. A careful check would use unrounded values, compare estimates and inferential quantities, and continue to a higher node count or an independent integration rule if those quantities remain sensitive.

Check the Estimates and the Inference

Numerical stability is an inferential question as well as a likelihood question. For each node count, inspect the parameters that matter to the scientific conclusion, including any selection parameter that is weakly identified. Compare standard errors, profile-likelihood curves or endpoints, and test statistics as appropriate. If the conclusion relies on whether an interval includes a particular value or a statistic crosses a prespecified cutoff, check whether the numerical changes could reverse that conclusion.

The numerical calculation does not determine which inferential method or calibration is appropriate. Use the intended method and assumptions consistently across quadrature comparisons. In particular, do not assume that a familiar reference distribution applies merely because the likelihood values are stable; selection-model constraints and weak identification can require careful calibration.

Worked Example: Does Quadrature Change an Interval Conclusion?

Suppose a hypothetical model has a selection parameter \(\gamma\), and an analyst uses a likelihood-ratio confidence interval with the same prespecified cutoff and calibration at every node count. Assume for this example that the parameter is interior, the likelihood is locally well-behaved, and the chosen calibration is justified for this setting. The interval endpoints returned by the same profiling procedure are:

Nodes \(K\)Estimate of \(\gamma\)Interval for \(\gamma\)
311.420[0.12, 2.89]
631.416[0.09, 2.93]
1271.415[0.08, 2.93]
2551.415[0.08, 2.93]

The estimate changes by \(1.416-1.420=-0.004\) from 31 to 63 nodes, then by \(1.415-1.416=-0.001\) from 63 to 127 nodes, and not at the displayed precision from 127 to 255 nodes. The lower endpoint changes from 0.12 to 0.08, while the upper endpoint changes from 2.89 to 2.93. Although the endpoints shift slightly, all four intervals exclude zero. Under the stated interval procedure, the qualitative conclusion about zero is therefore unchanged in these calculations.

This is evidence of stability for the reported conclusion, not proof that the integral is exact or that the model is well identified. The conclusion depends on the stated calibration being appropriate and on the displayed values representing sufficiently precise output. A different question—for example, whether the lower endpoint exceeds 0.10—would not have the same stability: the reported endpoints fall on both sides of 0.10.

Compare with an Independent Integration Rule

Increasing node counts tests convergence within a chosen family of quadrature rules. A second rule provides a different diagnostic. For example, a fixed-node Gaussian rule and an adaptive rule may respond differently to a sharply concentrated or tail-heavy integrand. Compare them first at the same parameter values to isolate integration differences; then, if needed, compare separately optimized fits to assess their effect on estimates.

Worked Example: Comparing a Fixed-Node and Adaptive Calculation

At a fixed hypothetical parameter vector, suppose one subject's positive likelihood contribution is approximated as 0.18420 using a high-node Gaussian rule and 0.18416 using adaptive integration. The absolute difference is \(0.18420-0.18416=0.00004\). Relative to the adaptive value, the difference is \(0.00004/0.18416\approx0.0002172\), or about 0.02172%.

On the log scale, the difference in this subject's contribution is \(\log(0.18420)-\log(0.18416)=\log(0.18420/0.18416)\approx0.0002172\). This close agreement is reassuring for this particular contribution and parameter vector. It does not, by itself, validate the full fit: errors across subjects can accumulate, and a refitted parameter vector could be sensitive to small changes in the objective.

Suppose the two methods, each used to fit the full hypothetical data set, give maximized log likelihoods of -203.81410 and -203.81409, and estimates of \(\gamma\) of 1.415 and 1.414. The log-likelihood difference is \(-203.81409-(-203.81410)=0.00001\), and the estimate difference is \(1.414-1.415=-0.001\). These small differences support numerical stability at the reported precision. The analyst should still inspect the inferential quantities and ensure that both rules evaluated the same likelihood with adequate optimization.

Diagnostics, Alternatives, and Limitations

Evidence that quadrature may be inadequate includes estimates or interval endpoints that continue to drift as nodes increase, unstable score or Hessian calculations, and changes in a test or interval conclusion across reasonable numerical settings. Large changes between two node counts are a clear warning. Small changes do not automatically clear the calculation, especially when a parameter is weakly identified or the decision is close to a cutoff.

Separate integration error from optimization error. Refit with suitable convergence checks at each node count; otherwise, an apparent quadrature effect may be an optimizer stopping effect. Conversely, optimizer convergence at each setting does not show that the integrated likelihood is accurate. Keep parameter constraints and starting strategies comparable, and check that the fitted values are not merely changing because one run reached a different local maximum.

Alternative integration rules can help, but they have limits. Adaptive methods may be more effective when the integrand is concentrated in a region that a fixed rule represents poorly, yet they also have tolerances and implementation choices that require checking. Simulation-based integration can be useful in some settings but may introduce Monte Carlo noise into the likelihood and its derivatives. No method should be treated as a numerical gold standard without diagnostics.

Quadrature validation cannot resolve model misspecification, weak identification, or uncertainty due to the observed sample. It assesses numerical approximation, not whether the selection model is scientifically adequate. Also, increasing nodes in multiple latent dimensions can be computationally expensive. The practical goal is not an unattainable declaration of exactness; it is a documented level of numerical stability adequate for the intended estimates and conclusions.

Common pitfall: “The optimizer converged, so the likelihood and estimates must be accurate.” Optimizer convergence concerns the approximate objective supplied to it. It does not establish that the quadrature approximates the intended integral well. Check increasing node counts, an independent integration rule when feasible, and the stability of the inferential quantities that matter.
1
Establish a baseline.
Record the node count, unrounded log likelihood, fitted parameters, and relevant inferential quantities for a converged fit.
2
Increase numerical resolution.
Refit at higher node counts while keeping the model and other settings fixed; compare successive results without assuming monotone convergence.
3
Cross-check when feasible.
Compare an independent integration rule, first at fixed parameters and then, if useful, after refitting.
4
Judge practical adequacy.
Decide whether remaining numerical differences could change the estimates, intervals, tests, or substantive conclusion. If they could, increase accuracy or report the sensitivity.

Check Your Understanding

Answer each question, then check the solutions below.

  1. A log-likelihood approximation changes from -82.4150 at one node count to -82.4146 at the next. What is the signed change, and why is its size alone not enough to validate the fit?
  2. Why can a small integration error produce a larger change in an estimate when the likelihood has weak curvature?
  3. A parameter estimate is stable across node counts, but an interval endpoint moves from 0.09 to 0.11. What should be checked before declaring the inference stable?
  4. What is the advantage, and one limitation, of comparing a fixed-node rule with adaptive integration?

Solutions. (1) The signed change is \(-82.4146-(-82.4150)=0.0004\). Its adequacy depends on the unrounded results and whether estimates and inferential quantities are sensitive; a small likelihood change alone is insufficient. (2) A flat likelihood has weak curvature, so the inverse Hessian can be large. The first-order estimate perturbation is approximately \(-H^{-1}e\), where \(e\) is the numerical score error. (3) Check the interval procedure and calibration are held fixed, inspect more precise endpoints and higher-resolution fits, and assess whether the endpoint crossing 0.10 changes the actual conclusion. (4) The rules can have different error patterns, so agreement is useful corroboration. But neither rule is automatically exact, and both require appropriate implementation and diagnostics.

Clinical Biostats