Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Hyperparameter Integration and Marginals in INLA

Bayesian Joint Models · Tutorial 335 of 697

Hyperparameter Integration and Marginals in INLA

You will learn to read INLA posterior marginals as hyperparameter-averaged distributions and to interpret the role of numerical integration in their uncertainty summaries.

Advanced 12 min read

What You'll Learn

  • Distinguish latent effects from model hyperparameters in an INLA fit
  • Explain how INLA approximates and integrates the hyperparameter posterior
  • Calculate a latent-effect marginal from conditional marginals and integration weights
  • Apply the law of total variance to separate conditional and hyperparameter uncertainty
  • Interpret hyperparameter summaries on their original and transformed scales
  • Recognize numerical integration and plug-in reporting pitfalls

Why the Marginals Require Integration

In a joint model, a longitudinal outcome and an event outcome can both provide information about shared latent effects. INLA represents such models using a latent Gaussian vector and a relatively low-dimensional vector of hyperparameters. The posterior distribution of a latent effect is therefore not, in general, just its conditional distribution at one selected hyperparameter value. It must also account for uncertainty about those hyperparameters.

This distinction matters for interpretation. A posterior mean or interval for a subject-specific random effect should reflect both uncertainty remaining when the hyperparameters are held fixed and variation in the effect's conditional distribution across plausible hyperparameter values. Similarly, a hyperparameter marginal is a posterior distribution, not merely an optimizer's point estimate.

Definition: In a latent Gaussian model, let \(y\) denote the observed data, \(x\) the latent Gaussian vector, and \(\theta\) the hyperparameter vector. The latent vector can include fixed effects and random effects; hyperparameters commonly include random-effect precisions, covariance parameters, and likelihood parameters. The precise allocation depends on the model parameterization. A posterior marginal for \(x_i\) or \(\theta_j\) is the posterior distribution of that component after integrating out all other unknown quantities.

A typical model has prior density \(p(x\mid\theta)\), likelihood \(p(y\mid x,\theta)\), and hyperparameter prior \(p(\theta)\). Its joint posterior is proportional to \(p(y\mid x,\theta)p(x\mid\theta)p(\theta)\). For a joint longitudinal-survival model, the likelihood can combine the longitudinal and event contributions conditional on the latent effects, as in the earlier material on encoding joint likelihoods in INLA. The marginal calculations described here do not require the two outcomes to be independent after the latent effects have been accounted for; they require the chosen likelihood and latent structure to represent their dependence appropriately.

INLA’s Approximation and Integration

INLA, the Integrated Nested Laplace Approximation, targets posterior marginals in latent Gaussian models by combining approximations with numerical integration over \(\theta\). First, for given \(\theta\), it approximates the conditional posterior of \(x\) and its relevant marginals. It also approximates the hyperparameter posterior, whose exact density is

$$ p(\theta\mid y) \propto p(\theta)\int p(y\mid x,\theta)p(x\mid\theta)\,dx. $$

The integral over the usually high-dimensional \(x\) is handled with a Laplace-based approximation. In outline, at each candidate \(\theta\), INLA finds a conditional posterior mode \(\hat{x}(\theta)\) and uses the curvature around that mode to approximate the integral. A standard Laplace form is

$$ \int p(y\mid x,\theta)p(x\mid\theta)\,dx \ \approx\ \frac{p(y\mid \hat{x}(\theta),\theta)p(\hat{x}(\theta)\mid\theta)} {p_G(\hat{x}(\theta)\mid y,\theta)}, $$

where \(p_G(x\mid y,\theta)\) is a Gaussian approximation to the conditional posterior of \(x\), evaluated at its mode in the denominator. INLA then explores the hyperparameter space and uses numerical integration to approximate posterior quantities. The conditional marginals may themselves use Gaussian or Laplace-based approximations; the choice of approximation affects the accuracy of the resulting marginal.

Key result: If \(\theta_k\) are integration points and \(\alpha_k\) are their normalized posterior integration weights, then a latent-component marginal is approximated by
$$ p(x_i\mid y) = \int p(x_i\mid y,\theta)p(\theta\mid y)\,d\theta \ \approx\ \sum_{k=1}^{K}\alpha_k\,\tilde p(x_i\mid y,\theta_k), \qquad \sum_{k=1}^{K}\alpha_k=1. $$

Here \(\tilde p(x_i\mid y,\theta_k)\) is INLA’s approximation to the conditional marginal at integration point \(\theta_k\). The weights represent the posterior mass assigned through the numerical integration scheme; they are not necessarily equal to the prior weights or to a simple grid spacing. The corresponding hyperparameter marginal is obtained by integrating or summarizing the approximate posterior over the other hyperparameters.

What Integration Does to Uncertainty

The effect of integration is especially clear for posterior means and variances. Write \(m(\theta)=E(x_i\mid y,\theta)\) and \(v(\theta)=\operatorname{Var}(x_i\mid y,\theta)\). The law of total expectation and law of total variance give

$$ E(x_i\mid y)=E_{\theta\mid y}\{m(\theta)\}, $$ $$ \operatorname{Var}(x_i\mid y) = E_{\theta\mid y}\{v(\theta)\} + \operatorname{Var}_{\theta\mid y}\{m(\theta)\}. $$

The first variance term averages the uncertainty conditional on hyperparameters. The second measures how the conditional mean changes over the posterior distribution of the hyperparameters. It is nonnegative, so ignoring hyperparameter uncertainty can omit a genuine component of posterior variance. This decomposition is also a useful check on calculations: a fully integrated variance cannot be smaller than the average conditional variance, apart from numerical approximation error.

Worked Example: Integrating a Random Effect’s Mean and Variance

Suppose an INLA calculation for a subject’s latent random effect \(b\) is summarized by two integration points. Their normalized posterior weights are \(0.70\) and \(0.30\). At the first point, the conditional posterior mean and variance of \(b\) are \(1.0\) and \(0.25\); at the second, they are \(3.0\) and \(1.00\). Treat these as hypothetical values, with \(b\) measured in the model’s latent-effect units.

The integrated mean is the weighted average of conditional means:

$$ E(b\mid y)\approx 0.70(1.0)+0.30(3.0)=1.60. $$

The average conditional variance is \(0.70(0.25)+0.30(1.00)=0.475\). The variation in conditional means is

$$ 0.70(1.0-1.60)^2+0.30(3.0-1.60)^2 =0.70(0.36)+0.30(1.96)=0.840. $$

Thus the integrated posterior variance is approximately \(0.475+0.840=1.315\), with posterior standard deviation \(\sqrt{1.315}\approx 1.147\) latent-effect units. Reporting only the first conditional distribution would give a mean of \(1.0\) and standard deviation \(0.50\), which fails to reflect the second hyperparameter region and its posterior weight.

Reading Hyperparameter Marginals and Scales

A hyperparameter marginal describes posterior uncertainty about a model component, such as a random-effect precision \(\tau\). A posterior mean, median, mode, or credible interval may answer different questions, especially when the marginal is skewed. The reported scale matters: a model may work internally with \(\eta=\log\tau\), while the scientific interpretation concerns \(\tau\). A posterior summary on the log scale is not generally the same as the corresponding summary on the precision scale.

For continuous variables, if \(\eta=\log\tau\), then \(\tau=\exp(\eta)\) and the densities are related by the change-of-variables rule:

$$ p_\tau(\tau\mid y) = p_\eta(\log\tau\mid y)\left|\frac{d\log\tau}{d\tau}\right| = \frac{p_\eta(\log\tau\mid y)}{\tau}, \qquad \tau>0. $$

A summary of \(\tau\) should be calculated from its posterior distribution on the precision scale, or by transforming draws or integration points and then summarizing with their posterior weights. For example, exponentiating the posterior mean of \(\log\tau\) gives a geometric-mean-type summary, not generally the posterior mean of \(\tau\).

Worked Example: Summarizing a Precision Marginal

Consider a hypothetical discrete integration summary for precision \(\tau\), with values \(1\), \(4\), and \(16\) carrying normalized posterior weights \(0.20\), \(0.50\), and \(0.30\). These points are illustrative, not a claim that an actual marginal has only three support points.

The weighted posterior mean on the precision scale is

$$ E(\tau\mid y)\approx 0.20(1)+0.50(4)+0.30(16)=7.00. $$

The weighted mean on the log scale is

$$ E(\log\tau\mid y)\approx 0.20\log(1)+0.50\log(4)+0.30\log(16) \approx 1.525. $$

Exponentiating gives \(\exp(1.525)\approx4.595\), which differs from \(7.00\). The difference is not a numerical contradiction: these are summaries on different scales. If precision has units inverse to the variance of a latent effect, the reported precision should retain those units; its reciprocal has variance units.

The same integration logic applies to posterior probabilities and quantiles. For an event \(A\) involving a latent or model parameter, \(P(A\mid y)\approx\sum_k\alpha_k P(A\mid y,\theta_k)\). For quantiles, the integrated marginal distribution is formed first, and the desired quantile is then found from that distribution. In general, averaging conditional quantiles does not give the quantile of the mixture.

Worked Example: A Posterior Probability for an Association Coefficient

Let \(\gamma\) be a survival association coefficient, interpreted so that a one-unit increase in the linked latent quantity changes the log hazard by \(\gamma\). Consider three hypothetical hyperparameter integration points with normalized weights \(0.20\), \(0.50\), and \(0.30\). Suppose the corresponding conditional posterior probabilities \(P(\gamma>0\mid y,\theta_k)\) are \(0.02\), \(0.25\), and \(0.90\).

The integrated probability is

$$ P(\gamma>0\mid y) \approx 0.20(0.02)+0.50(0.25)+0.30(0.90) =0.004+0.125+0.270=0.399. $$

Thus the approximate posterior probability that \(\gamma\) is positive is \(0.399\), or \(39.9\%\), under this hypothetical calculation. It is not the conditional probability at the most heavily weighted point, \(0.25\), nor does it state the probability that a null hypothesis is true. The interpretation is conditional on the specified model and data.

Diagnostics, Alternatives, and Limitations

Numerical integration is part of the inferential calculation, so inspect whether it is representing the posterior mass adequately. Useful checks include reviewing the shape and range of hyperparameter marginals, checking whether substantial mass lies near a boundary or beyond the explored region, and assessing whether summaries change when integration settings are refined. Concentrated or irregular weights can signal that a small number of integration points dominate; this does not by itself prove an error, but it warrants checking that the posterior region has been adequately explored. Also verify that the reported parameter is on the intended scale and that all weights used in a manual summary are normalized.

These checks concern numerical representation, not whether the model is scientifically appropriate. Even accurate integration cannot correct a misspecified likelihood, prior, or latent structure. INLA results also inherit error from the nested approximations: the conditional posterior and the hyperparameter posterior are approximated, and numerical integration is finite. Consequently, extra displayed digits do not guarantee corresponding inferential accuracy.

ApproachWhat it reportsMain distinction
Hyperparameter-integrated INLA marginalA marginal distribution averaged over the approximate posterior of \(\theta\)Includes both conditional uncertainty and variation across hyperparameter values
Conditional summary at a fixed \(\theta\)A distribution for \(x_i\) with hyperparameters held fixedDoes not include variation in the conditional distribution across \(\theta\)
Plug-in or empirical Bayes summaryA summary evaluated at a selected hyperparameter estimateCan be computationally convenient, but is not the same as integration over \(p(\theta\mid y)\)

A conditional or plug-in result can be useful as a computational shortcut or a focused diagnostic, provided it is labelled clearly. It should not be presented as the fully integrated posterior marginal. Conversely, integration does not make the result automatically reliable: the approximation and integration scheme still need suitable numerical behavior, and uncertainty summaries remain conditional on the model.

1
Identify the quantity and scale.
Determine whether the output is a latent effect, a hyperparameter, or a transformed version of one, and record its units or interpretation.
2
Determine whether the marginal is integrated.
For a latent effect, check that the reported marginal combines conditional marginals over hyperparameter integration points rather than using only a fixed estimate.
3
Check the numerical summary.
Confirm that posterior weights are normalized, transformations are handled on the correct scale, and the integration results are stable enough for the intended interpretation.

Common Mistake

A common mistake is to treat the conditional posterior at the estimated hyperparameters as though it were the marginal posterior. For example, one might use the conditional standard deviation of a random effect as its full posterior standard deviation. The correction is to integrate the conditional distribution over the hyperparameter posterior. For variances, this adds the variation in conditional means, as shown by \(\operatorname{Var}(x_i\mid y)=E\{v(\theta)\mid y\}+\operatorname{Var}\{m(\theta)\mid y\}\). A second mistake is to average conditional credible-interval endpoints and call the result an integrated credible interval; instead, form the mixture marginal and calculate its quantiles.

Key takeaway: An INLA posterior marginal is an approximation to a distribution after nuisance quantities have been integrated out. Hyperparameter integration combines conditional uncertainty across plausible hyperparameter values, so it can materially affect latent-effect uncertainty, tail probabilities, and summaries on transformed scales.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. Two equally weighted integration points give conditional means \(0\) and \(2\), with conditional variances \(1\) at both points. Find the integrated mean and variance.
  2. A hyperparameter marginal has values \(2\) and \(8\) with weights \(0.75\) and \(0.25\). Find its posterior mean.
  3. Conditional probabilities of an event \(A\) are \(0.10\) and \(0.70\) at two points with weights \(0.40\) and \(0.60\). Find the integrated posterior probability.
  4. Why is exponentiating \(E(\log\tau\mid y)\) generally not equal to \(E(\tau\mid y)\)?

Solutions. (1) The mean is \(0.50(0)+0.50(2)=1\). The average conditional variance is \(1\), and the variance of conditional means is \(0.50(0-1)^2+0.50(2-1)^2=1\), so the integrated variance is \(2\). (2) The mean is \(0.75(2)+0.25(8)=3.50\). (3) The integrated probability is \(0.40(0.10)+0.60(0.70)=0.46\). (4) The exponential is nonlinear, so transforming a posterior mean on the log scale does not in general give the mean on the original scale; the original-scale mean must be calculated from the transformed posterior distribution.

Clinical Biostats