Tutorials › Generalized Linear Mixed Models (GLMM) › Blocking Updates for Correlated Random Effects

Bayesian GLMM and Prior Specification for Variance Components · Tutorial 277 of 698

Blocking Updates for Correlated Random Effects

See how the choice of MCMC update blocks interacts with posterior correlation, and work through calculations that clarify the trade-offs.

Advanced 11 min read

What You'll Learn

  • Write the conditional posterior target for correlated group-level effects in a GLMM.
  • Distinguish joint vector updates from sequential componentwise updates.
  • Derive why componentwise Gibbs updates can mix slowly under strong posterior correlation.
  • Calculate a Metropolis–Hastings acceptance probability for a joint proposal.
  • Compare blocking choices and identify signs that an update strategy may be inefficient.

Why the Update Block Matters

In a Bayesian GLMM, random effects for the same group may be correlated. The sampler must then move through a posterior distribution whose high-probability region can be tilted or elongated. Updating one coefficient at a time is valid when each update targets the correct conditional distribution, but it may make only small effective progress: changing one coefficient while holding its correlated partner fixed can repeatedly move the chain away from the high-probability region. Updating the coefficients together can let the chain move along that region instead.

The choice is not simply “joint is better.” A joint update may require a more demanding proposal or more computation, and a poorly chosen joint proposal can also mix badly. The useful question is which block structure produces adequate movement for the cost, while preserving the intended posterior distribution.

Posterior Target and Update Blocks

Consider a GLMM with groups \(j=1,\ldots,J\) and observations \(i=1,\ldots,n_j\). Let \(y_{ij}\) be the response, \(x_{ij}\) the fixed-effect design vector, and \(z_{ij}\) the random-effect design vector. Write the linear predictor as \(\eta_{ij}=x_{ij}^{\mathsf T}\beta+z_{ij}^{\mathsf T}b_j\), with the response distribution and link specified by the GLMM. Suppose the group-level vectors are conditionally independent given covariance parameters and satisfy \(b_j\sim N_q(0,\Sigma)\). A common decomposition is \(\Sigma=DRD\), where \(D\) contains random-effect standard deviations and \(R\) is a correlation matrix.

Let \(\theta\) collect fixed effects, covariance parameters, and any other model parameters. For observed data \(y\), the posterior target for the random effects and parameters is proportional to the conditional likelihood times the random-effects density and parameter priors:

$$ \pi(b_1,\ldots,b_J,\theta\mid y) \propto \left\{\prod_{j=1}^{J}\prod_{i=1}^{n_j} p(y_{ij}\mid b_j,\theta)\right\} \left\{\prod_{j=1}^{J}\phi_q(b_j;0,\Sigma)\right\} p(\theta). $$

Here \(\phi_q(\,\cdot\,;0,\Sigma)\) is the \(q\)-dimensional normal density. The grouping structure makes each group’s likelihood contribution local to \(b_j\), but the prior covariance couples the components of that vector. This tutorial assumes the model and priors define a proper posterior, \(\Sigma\) is positive definite wherever the posterior has support, and each sampling transition is constructed to leave the posterior invariant. For Metropolis–Hastings updates, the proposal and acceptance probability must account for the target density and proposal probabilities.

Definition: A joint (blocked) update proposes or draws multiple parameters together in one transition. A componentwise update updates one parameter, or one scalar component of a vector, at a time while conditioning on the current values of the other components. A sequence of valid componentwise transitions can target the same posterior as a joint transition, but the resulting chains need not have the same mixing efficiency.

For correlated random effects, a natural middle ground is to update the \(q\) components of one group’s \(b_j\) as a block, rather than updating every random effect in the entire model simultaneously. A further option is a larger block containing random effects and some covariance parameters. Each design changes the dimension and geometry of the transition. The posterior target remains the same; what changes is how efficiently the chain explores it.

Worked Example: Covariance in a Random-Intercept and Random-Slope Block

Suppose a hypothetical binary-outcome GLMM has a random intercept and a random slope for a standardized predictor in each clinic. The prior for a clinic’s two-dimensional effect is \(b_j\sim N_2(0,\Sigma)\). Let the hypothetical standard deviations be \(0.80\) for the intercept and \(0.30\) for the slope, with correlation \(0.75\).

The standard-deviation matrix is \(D=\operatorname{diag}(0.80,0.30)\), and the correlation matrix is \[ R=\begin{pmatrix}1&0.75\\0.75&1\end{pmatrix}. \] Therefore, \[ \Sigma=DRD =\begin{pmatrix} 0.80^2 & (0.80)(0.30)(0.75)\\ (0.80)(0.30)(0.75)&0.30^2 \end{pmatrix} =\begin{pmatrix}0.64&0.18\\0.18&0.09\end{pmatrix}. \]

The covariance is \(0.18\), and the corresponding correlation is \(0.18/(0.80\times0.30)=0.75\). Thus, large intercept deviations tend to accompany large slope deviations under the group-level distribution. A joint update of the clinic’s intercept and slope can propose changes that respect this dependence. A componentwise update can still be correct, but it changes one coordinate with the other held fixed at each substep.

Why Strong Correlation Can Slow Componentwise Gibbs Updates

The effect of blocking can be seen exactly in a simple bivariate normal target. This calculation is a geometric illustration of posterior dependence, not a claim that a logistic GLMM’s conditional posterior is exactly normal. Suppose the target for two scalar effects \(U,V\) is standard bivariate normal with correlation \(r\), where \(-1<r<1\). Its conditional distributions are \(U\mid V=v\sim N(rv,1-r^2)\) and \(V\mid U=u\sim N(ru,1-r^2)\).

A systematic componentwise Gibbs sweep first draws \(U_{t+1}\) given \(V_t\), then draws \(V_{t+1}\) given \(U_{t+1}\). Write the independent standard normal innovations as \(\epsilon_{t+1}\) and \(\zeta_{t+1}\). The two conditional draws are

$$ U_{t+1}=rV_t+\sqrt{1-r^2}\,\epsilon_{t+1}, \qquad V_{t+1}=rU_{t+1}+\sqrt{1-r^2}\,\zeta_{t+1}. $$

Substituting the first equation into the second gives \(V_{t+1}=r^2V_t+r\sqrt{1-r^2}\epsilon_{t+1}+\sqrt{1-r^2}\zeta_{t+1}\). The innovations are independent of the current state, so the lag-one correlation of the stationary \(V\) chain is \(r^2\). As \(|r|\) approaches one, this correlation approaches one: successive sweeps retain much of the previous state. A joint draw directly from the bivariate target, by contrast, produces independent successive draws in this special case.

That comparison has a qualification: an exact joint draw is available here because the target is a known normal distribution. In a GLMM, a joint update may instead require a Metropolis proposal, Hamiltonian Monte Carlo, or another transition. A joint transition is not automatically independent, and its efficiency depends on how well it follows the posterior geometry.

Worked Example: Calculating the Componentwise Dependence

Suppose the conditional posterior for two hypothetical group effects is approximated by a bivariate normal distribution with correlation \(r=0.90\). Under the systematic Gibbs scheme above, the lag-one correlation for either coordinate after a full sweep is \(r^2\).

Substitution gives \(0.90^2=0.81\). Thus, in this idealized normal calculation, adjacent values of a coordinate have correlation \(0.81\), indicating substantial persistence. As a rough comparison, the large-sample effective sample size for a stationary chain with an AR(1)-like autocorrelation of \(0.81\) is \(N(1-0.81)/(1+0.81)\). For \(N=10{,}000\) retained draws, this is approximately \(10{,}000(0.19/1.81)=1{,}050\) effective draws.

This effective-sample-size calculation is only an illustration based on the stated autocorrelation approximation; it is not a general guarantee for a GLMM chain. It shows why counting stored iterations alone can overstate how much information a highly persistent componentwise chain contains.

Designing a Joint Metropolis Update

When the conditional posterior is not available in a convenient closed form, a block can be updated using Metropolis–Hastings. Given the current state \(b\), propose \(b'\) from \(q(b'\mid b)\) and accept it with probability

$$ \alpha(b,b')= \min\left\{1,\, \frac{\pi(b'\mid y,\theta)\,q(b\mid b')} {\pi(b\mid y,\theta)\,q(b'\mid b)} \right\}. $$

For a symmetric proposal, \(q(b'\mid b)=q(b\mid b')\), so the proposal terms cancel. A useful joint proposal often accounts for the orientation and scale of the conditional posterior: proposals along a long, high-density direction can move farther than proposals that repeatedly cross a narrow direction. The target covariance is not necessarily the same as the prior covariance \(\Sigma\), because the likelihood also informs the random effects.

Worked Example: Acceptance for a Symmetric Joint Proposal

Continue with a hypothetical bivariate normal conditional target having correlation \(0.90\), unit marginal variances, and zero means. Its log density, omitting a constant common to all states, is \[ \ell(u,v)=-\frac{1}{2(1-r^2)}(u^2-2ruv+v^2). \] Suppose a symmetric joint proposal moves from \((u,v)=(1,-1)\) to \((0.8,-0.8)\). The proposal is symmetric, so the acceptance probability is \(\min\{1,\exp[\ell(0.8,-0.8)-\ell(1,-1)]\}\).

At \((1,-1)\), the quadratic numerator is \(1-2(0.90)(-1)+1=3.8\), and \(1-r^2=0.19\). The quadratic form is \(3.8/0.19=20\), so the log density, up to its constant, is \(-10\). At \((0.8,-0.8)\), the numerator is \(0.64-2(0.90)(-0.64)+0.64=2.432\), giving \(2.432/0.19=12.8\) and log density \(-6.4\). Therefore the log-density difference is \(3.6\), and \[ \alpha=\min\{1,\exp(3.6)\}=1. \]

This proposed move is accepted with probability one because it increases the target density. The calculation does not show that every joint proposal will be efficient: a symmetric proposal aimed in a direction poorly matched to the tilted target can have low acceptance or make only short effective moves.

Choosing a Block and Checking Its Behaviour

In practice, block size is a balance between dependence and computational cost. Updating each group’s random-effect vector together can address within-group correlation without building one very large proposal for all groups. If the posterior dependence is weak, scalar updates may be simpler and can work adequately. If strong dependence involves both random effects and covariance parameters, a block that includes only the effects may leave important dependence untouched; a larger block can help, but is more demanding to design and compute.

A sensible comparison asks whether the chain makes movement in the posterior directions that matter, not just whether each update is accepted. Useful preliminary checks include plotting draws of correlated effects together, inspecting trace plots, and examining autocorrelation for representative coordinates or posterior summaries. Persistent traces, narrow bands of points in joint plots, or slow changes in quantities such as a random-effect contrast can signal that the chosen updates are not exploring efficiently. These signs do not by themselves identify the cause; initialization, parameterization, or other features of the posterior may also contribute.

The main alternatives have different trade-offs:

Update strategyPotential advantagePotential limitation
Scalar componentwise updatesSimple and relatively inexpensive per substepMay move slowly when correlated coordinates must change together
One group-level vector blockCan follow dependence among that group’s random effectsRequires a suitable multivariate transition; cost grows with block dimension
Large block across groups or parametersMay address broader posterior dependence in one transitionCan be computationally expensive and difficult to tune or construct effectively

Regardless of block choice, correctness and efficiency are separate questions. A valid transition must preserve the posterior target and allow the chain to reach the relevant posterior regions under its support and transition structure. A transition can be correct but inefficient; a move that appears to improve mixing is not valid if its acceptance rule omits a required density or proposal term. Blocking also cannot repair a misspecified model or an inappropriate prior.

Common Pitfall

Wrong reasoning: “The random effects are correlated, so a joint update must always be better.” Correlation gives a reason to consider blocking, but not proof that a particular block or proposal will perform well. A large, poorly scaled joint proposal can be rejected often, while a componentwise scheme can be quite adequate when dependence is modest or its conditional updates are effective.

Correction: Treat blocking as an algorithmic choice to assess. State the target, use a transition that preserves it, and compare the movement and computational cost obtained from plausible block structures. Strong posterior dependence makes joint updating a useful candidate, not a universal rule.

Key takeaway: Correlation can make componentwise updates move slowly because one effect is repeatedly held fixed while its partner changes. Blocking correlated effects can align updates with joint posterior movement, but the best choice depends on posterior geometry, proposal quality, and computational cost.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. If two coordinates in the bivariate normal Gibbs example have correlation \(r=-0.80\), what is the lag-one correlation for a coordinate after a full systematic sweep?
  2. A sampler proposes a random-effect vector jointly with a symmetric proposal. What terms remain in the Metropolis–Hastings acceptance ratio?
  3. Why might updating each group’s random-effect vector jointly be preferable to updating every group’s effects in one very large block?
  4. Does a high acceptance rate by itself establish that a block is mixing efficiently? Explain.

Solutions. (1) The lag-one correlation is \(r^2=(-0.80)^2=0.64\); its sign is positive because the systematic two-step sweep squares the correlation. (2) The proposal terms cancel, leaving \(\min\{1,\pi(b'\mid y,\theta)/\pi(b\mid y,\theta)\}\). (3) A group-level block can address dependence among that group’s coefficients while keeping the dimension of each update smaller; a single very large block may cost more and be harder to construct effectively. (4) No. Acceptance records whether proposals are retained, not how far the chain moves through important posterior directions. A high acceptance rate can accompany tiny, highly correlated steps, so movement and persistence also matter.

Clinical Biostats