Tutorials › Generalized Linear Mixed Models (GLMM) › Conditional Modes and Posterior Means in GLMMs

Prediction of Random Effects · Tutorial 454 of 698

Conditional Modes and Posterior Means in GLMMs

Learn how a GLMM’s conditional distribution of a group effect leads to a mode or a mean prediction, and why non-Gaussian likelihoods can make those predictions differ.

Advanced 10 min read

What You'll Learn

  • Define a conditional mode and a posterior mean for a group effect in a GLMM.
  • Distinguish prediction conditional on fitted parameters from uncertainty about those parameters.
  • Derive a posterior mean for a probit random-intercept example.
  • Calculate and interpret the conditional mode and mean when they differ.
  • Identify why Gaussian conditional distributions make these summaries coincide.
  • Recognize when skewness, multimodality, or sparse information makes a single prediction incomplete.

Two summaries of the same group-effect distribution

A GLMM does not generally produce one uniquely mandated prediction of a group’s latent effect. After observing that group’s outcomes, the model gives a conditional distribution for its random effect. A conditional mode reports the location where that distribution is highest; a posterior mean reports its average. These summaries answer related but different questions, and for a non-Gaussian response model they need not be equal.

The distinction matters because a reported group effect is often used to describe how a group differs from the population-level model. If the conditional distribution is asymmetric, its most typical density location and its average can differ appreciably. Neither summary is automatically the “correct” one for every purpose: the choice should reflect the target of prediction and should be reported clearly.

Definition: Let \(Y_j\) denote the observed outcomes in group \(j\), \(b_j\) its random effect, and \(\theta\) the model parameters (including fixed effects and random-effect covariance parameters). Conditional on fitted values \(\hat{\theta}\), the conditional distribution of the group effect has density \(p(b_j\mid Y_j,\hat{\theta})\), proportional to the group likelihood \(p(Y_j\mid b_j,\hat{\theta})\) times the random-effect density \(p(b_j\mid\hat{\theta})\). The conditional mode is a value \(b_j^{\mathrm{mode}}\) maximizing this density. The posterior mean is \(b_j^{\mathrm{mean}}=E(b_j\mid Y_j,\hat{\theta})\), provided that expectation exists. Both are conditional on the fitted parameters; they do not, by themselves, incorporate uncertainty in \(\hat{\theta}\).

This use of “posterior” is standard in empirical Bayes prediction: the random effect is treated as having a prior distribution supplied by the GLMM, and the group’s outcomes update that distribution. The mode is also called a conditional mode or a maximum a posteriori (MAP) estimate. The mean is also called a conditional expectation. For vector random effects, the same definitions apply to the joint conditional density and expectation; componentwise modes need not equal the components of a joint mode in every parameterization.

Why likelihood shape determines whether the summaries agree

For a Gaussian response model with a Gaussian random effect, the conditional distribution of the group effect is Gaussian. A Gaussian density is symmetric and its mean, median, and mode coincide. Thus the conditional mode and posterior mean agree in that setting. This equality is not a general property of random-effects prediction; it follows from the shape of that conditional distribution.

In a non-Gaussian GLMM, the likelihood contribution as a function of \(b_j\) is generally not quadratic. Combining it with a normal random-effect density can yield a conditional distribution that is skewed or otherwise non-Gaussian. A mode depends on the peak, while a mean averages across the entire distribution, including its longer tail. Thus the difference can be understood directly from the definitions, without treating either summary as a computational error.

To use either summary, the model must specify the conditional outcome distribution and link, the random-effect distribution, and the way observations are conditionally independent given the random effects and covariates. The calculations below also treat \(\hat{\theta}\) as fixed. If those assumptions are inadequate, the resulting conditional distribution and both predictions may be misleading.

Worked Example: A Probit Random Intercept with One Success

Suppose a hypothetical group has one binary outcome \(Y\), with \(Y\mid b\sim\operatorname{Bernoulli}(\Phi(b))\), where \(\Phi\) is the standard normal cumulative distribution function. The group intercept has prior distribution \(b\sim N(0,t)\), where \(t=(1+\sqrt{5})/2\approx1.618\). For the observed outcome \(Y=1\), compare the conditional mode and posterior mean.

The likelihood for this observation is \(\Phi(b)\), so the conditional density is proportional to \(\Phi(b)\) times the \(N(0,t)\) density. The normalizing constant is \(P(Y=1)=E\{\Phi(b)\}=0.5\): symmetry of \(b\) around zero and \(\Phi(-b)=1-\Phi(b)\) make the average equal to one half.

For the numerator of the posterior mean, introduce an independent \(Z\sim N(0,1)\). Since \(\Phi(b)=P(Z\leq b)\), the numerator is \(E\{b\,I(Z\leq b)\}\), where \(I\) is an indicator. Let \(D=b-Z\). Then \(D\sim N(0,t+1)\) and \(\operatorname{Cov}(b,D)=t\). The standard bivariate-normal truncated-moment identity gives \(E\{bI(D\geq0)\}=\operatorname{Cov}(b,D)/\sqrt{\operatorname{Var}(D)}\times\phi(0)\), where \(\phi\) is the standard normal density. Therefore,

$$ E(b\mid Y=1) =\frac{\dfrac{t}{\sqrt{t+1}}\phi(0)}{0.5} =\frac{t}{\sqrt{t+1}}\,2\phi(0). $$

Here \(t^2=t+1\), so \(t/\sqrt{t+1}=1\). Since \(2\phi(0)=2/\sqrt{2\pi}\approx0.7979\), the posterior mean is \(0.7979\) on the probit linear-predictor scale. Using unrounded values, the numerator is approximately \(0.3989423\), and dividing by \(0.5\) gives approximately \(0.7978846\), which rounds to \(0.7979\).

The mode maximizes the log conditional density \(\log\{\Phi(b)\}-b^2/(2t)\), ignoring terms constant in \(b\). Its derivative is \(-b/t+\phi(b)/\Phi(b)\). Setting this equal to zero and solving numerically gives \(b^{\mathrm{mode}}\approx0.6808\). Thus the mean is about \(0.1171\) higher than the mode. Both indicate a positive group effect after a success, but they are not interchangeable numerical predictions. The model assumptions here are explicitly a probit Bernoulli likelihood and a normal random intercept; the difference arises from the resulting non-Gaussian conditional distribution.

Deriving the mode and mean in practice

The mode is usually found by maximizing a log density, while the mean requires integration over the whole conditional distribution. The distinction can be expressed as two separate operations:

$$ b_j^{\mathrm{mode}} =\underset{b}{\operatorname{arg\,max}}\, \left\{\log p(Y_j\mid b,\hat{\theta})+\log p(b\mid\hat{\theta})\right\}, \qquad b_j^{\mathrm{mean}} =\frac{\int b\,p(Y_j\mid b,\hat{\theta})p(b\mid\hat{\theta})\,db} {\int p(Y_j\mid b,\hat{\theta})p(b\mid\hat{\theta})\,db}. $$

For vector \(b\), replace the integral by a multidimensional integral and the scalar maximum by a maximizer of the joint density. The maximization is often computationally more direct than calculating an expectation, though neither operation removes the need to evaluate the likelihood and account for the random-effect distribution.

1
Form the conditional density.
Multiply the group’s likelihood contribution by the random-effect density, using the specified model and fitted parameters.
2
Choose the summary that matches the target.
For a peak-density summary, maximize the log conditional density. For an average-effect summary, calculate its conditional expectation.
3
Check the distribution and calculation.
Inspect the conditional density or a numerical approximation for skewness, multiple peaks, or numerical instability; report the chosen summary and its scale.

Worked Example: A Symmetric Gaussian Conditional Distribution

Suppose, in a hypothetical Gaussian random-intercept model, the conditional distribution for a group effect after observing its data is \(b_j\mid Y_j,\hat{\theta}\sim N(0.60,0.25)\), where the second parameter is the variance. The conditional standard deviation is \(\sqrt{0.25}=0.50\).

The normal density is maximized at its mean, so \(b_j^{\mathrm{mode}}=0.60\). Its expectation is also \(b_j^{\mathrm{mean}}=0.60\). Both predictions are \(0.60\) units on the random-intercept scale. This agreement is justified by the stated Gaussian conditional distribution; it should not be assumed merely because the random effects were initially specified as normal.

For example, a non-Gaussian outcome likelihood can change the shape of the conditional distribution even when the random-effect distribution is normal. In that case the Gaussian equality need not hold. Also, the value \(0.60\) is a prediction of the latent group effect, not a response probability or an observed outcome.

Worked Example: Symmetry Reverses the Prediction After a Failure

Use the probit model and prior from the first worked example, but now observe \(Y=0\). The likelihood is \(1-\Phi(b)=\Phi(-b)\). Because the prior density is symmetric around zero, the conditional density for this observation is the reflection of the conditional density for \(Y=1\).

Reflecting the previous conditional distribution changes the sign of both its mean and its mode. Therefore \(b^{\mathrm{mean}}=-0.7979\), and \(b^{\mathrm{mode}}\approx-0.6808\). The posterior mean is again lower than the mode, now by approximately \(0.1171\). These values are group-effect predictions on the probit scale; they are not probabilities. The result depends on the stated symmetry and on observing one failure in this particular model.

Choosing, checking, and reporting a prediction

A conditional mode is useful when the desired summary is the most densely supported location, and it is often convenient in likelihood-based computations. A posterior mean is appropriate when the target is the average latent group effect under the conditional distribution. For a nonlinear transformation or a response-scale prediction, transforming a mean group effect is not generally the same as averaging the transformed response over the conditional distribution. The target should therefore be defined before selecting a summary.

A single point prediction can also conceal important features. In particular, a distribution may be skewed, have a long tail, or have more than one local peak. In a multimodal distribution, a mode can depend on which peak the numerical optimizer finds; the mean may lie in a low-density region between peaks. Numerical integration or optimization should be checked for convergence, and a plotted or tabulated conditional density can reveal features a lone number cannot.

The main alternative is not a third point summary but a description of the conditional distribution itself, such as its spread or an interval. Such summaries communicate uncertainty in the group effect rather than reducing the distribution to one location. They still condition on fitted parameters unless parameter uncertainty is separately included. An empirical Bayes point prediction, whether mode or mean, also depends on estimated model parameters and can be sensitive to model misspecification, limited information within a group, or an unsuitable random-effect distribution.

Common pitfall: “The random effects are normal, so the conditional mode and posterior mean must be equal.” This reasoning confuses the random-effect distribution before observing a group’s outcomes with its conditional distribution after those outcomes update it. The correction is to form \(p(b_j\mid Y_j,\hat{\theta})\) first and determine its shape; equality follows when that conditional distribution is symmetric Gaussian, not simply because its prior was normal.

When reporting a prediction, state whether it is a conditional mode or posterior mean, identify the group-effect scale (for example, the log-odds or probit scale), and clarify that fitted parameters were treated as fixed if that is what the calculation did. If both summaries differ materially, reporting both can be informative, provided their roles are explained rather than presented as competing estimates of a single uniquely defined quantity.

Check Your Understanding

Answer each question, then compare with the short solutions.

  1. Define the conditional mode and posterior mean in terms of \(p(b_j\mid Y_j,\hat{\theta})\).
  2. In the probit example with one success, why is the normalizing constant \(0.5000\), and what is the corrected posterior mean?
  3. What property of a Gaussian conditional distribution makes its mode and mean coincide?
  4. Suppose a conditional distribution is strongly right-skewed. Why can its mean exceed its mode?
  5. Why is a normal random-effect prior alone insufficient to conclude that conditional modes equal posterior means?

Solutions. (1) The mode maximizes the conditional density; the mean is its expectation. (2) Symmetry gives \(E\{\Phi(b)\}=0.5\); using unrounded values, the numerator is approximately \(0.3989423\), so the mean is \(0.3989423/0.5\approx0.7978846\), which rounds to \(0.7979\). (3) A Gaussian density is symmetric and maximized at its mean. (4) A long right tail contributes to the average and can pull the mean above the density peak. (5) The observed-data likelihood updates the prior, and the resulting conditional distribution need not be Gaussian even when the prior is normal.

Clinical Biostats