Tutorials › Nonlinear Mixed-Effects Models (NLME) › Random-Effect Correlation in Approximate Likelihoods

The Marginal Likelihood and Its Approximations · Tutorial 162 of 797

Random-Effect Correlation in Approximate Likelihoods

Learn to trace random-effect correlation through the quadratic penalty and determinant terms in FO, FOCE, and Laplace calculations.

Advanced 12 min read

What You'll Learn

  • Write the bivariate random-effect covariance matrix and its inverse in terms of variances and correlation.
  • Derive the covariance and determinant terms in a first-order marginal likelihood.
  • Explain how FOCE linearization changes while retaining the same correlated prior.
  • Identify the Hessian determinant contribution to a Laplace approximation.
  • Check positive definiteness and diagnose numerical problems caused by extreme correlations.

Why Correlation Changes an Approximate Likelihood

In an NLME model, random effects can represent related subject-specific features, such as clearance and volume. If those effects are correlated, a subject with a higher-than-typical value of one may tend to have a higher or lower value of the other. This relationship matters even when the model’s predictions are locally linear: it changes which combinations of effects are likely, how uncertainty propagates to observations, and the determinant terms that normalize a likelihood.

The key is to carry the full random-effect covariance matrix through each calculation. Replacing it with its diagonal entries is not a harmless simplification: it changes the prior penalty, the induced observation covariance, and often the curvature determinant. The formulas below use a subject with \(q\) random effects and \(m\) observations, additive Gaussian residual error with covariance \(R\), and a positive-definite random-effect covariance matrix \(\Omega\). The focus is the role of correlation, not the choice of residual-error model.

Definition: For a subject, let \(\eta\in\mathbb{R}^q\) denote the vector of random effects, with \(\eta\sim N(0,\Omega)\). Its density is $$ p(\eta)= (2\pi)^{-q/2}|\Omega|^{-1/2} \exp\left(-\frac{1}{2}\eta^\mathsf{T}\Omega^{-1}\eta\right). $$ The matrix \(\Omega\) describes variances on its diagonal and covariances off the diagonal. Its inverse determines the quadratic prior penalty, and its determinant provides the density’s normalizing factor.

Covariance, Inverse, and Determinant

For two random effects with standard deviations \(\omega_1,\omega_2\) and correlation \(\rho\), the covariance matrix is

$$ \Omega= \begin{pmatrix} \omega_1^2 & \rho\omega_1\omega_2\\ \rho\omega_1\omega_2 & \omega_2^2 \end{pmatrix}, \qquad |\Omega|=\omega_1^2\omega_2^2(1-\rho^2). $$

A valid nonsingular covariance matrix requires \(\omega_1>0\), \(\omega_2>0\), and \(|\rho|<1\). Its inverse is

$$ \Omega^{-1} = \frac{1}{1-\rho^2} \begin{pmatrix} 1/\omega_1^2 & -\rho/(\omega_1\omega_2)\\ -\rho/(\omega_1\omega_2) & 1/\omega_2^2 \end{pmatrix}. $$

The off-diagonal terms in the inverse mean that the prior penalty is not generally a sum of separate penalties for each random effect. For a vector \(\eta=(\eta_1,\eta_2)^\mathsf{T}\), that penalty is

$$ \eta^\mathsf{T}\Omega^{-1}\eta = \frac{1}{1-\rho^2} \left[ \frac{\eta_1^2}{\omega_1^2} -\frac{2\rho\eta_1\eta_2}{\omega_1\omega_2} +\frac{\eta_2^2}{\omega_2^2} \right]. $$

Thus, the relative plausibility of a pair of effects depends on their joint direction, not only on their separate magnitudes. The determinant also changes with \(\rho\): as the absolute correlation approaches one, the bivariate distribution becomes concentrated near a line, and \(|\Omega|\) approaches zero.

Worked Example: Inverting a Correlated Random-Effect Covariance

Suppose two hypothetical random effects have standard deviations \(0.5\) and \(0.6\), with correlation \(0.5\). Then their covariance is \(0.5(0.5)(0.6)=0.15\), so

$$ \Omega= \begin{pmatrix}0.25&0.15\\0.15&0.36\end{pmatrix}. $$

The determinant is $$ |\Omega|=(0.25)(0.36)-(0.15)^2=0.09-0.0225=0.0675. $$ It is positive, as required. The inverse is $$ \Omega^{-1} =\frac{1}{0.0675} \begin{pmatrix}0.36&-0.15\\-0.15&0.25\end{pmatrix} = \begin{pmatrix}5.333&-2.222\\-2.222&3.704\end{pmatrix}. $$

For the illustrative effect vector \(\eta=(0.2,0.1)^\mathsf{T}\), the quadratic penalty is approximately $$ (0.2,0.1) \begin{pmatrix}5.333&-2.222\\-2.222&3.704\end{pmatrix} \begin{pmatrix}0.2\\0.1\end{pmatrix} =0.2133-0.0889+0.0370\approx0.1615. $$ For the specific illustrative vector \((0.2,0.1)^\mathsf{T}\), the correlated prior has a smaller quadratic penalty than the independent prior with the same marginal variances; same signs alone do not guarantee this.

FO: Correlation Propagates Into Observation Covariance

Let \(y\) be the vector of observations and \(f(\eta)\) the model prediction vector at the fixed effects under consideration. In the first-order (FO) approximation, linearize the prediction around the population random-effect value \(\eta=0\): $$ f(\eta)\approx f(0)+G\eta, $$ where \(G\) is the \(m\times q\) derivative matrix at zero. With additive Gaussian residual error of covariance \(R\), the linearized observation model is Gaussian. Integrating over the random effects gives mean \(f(0)\) and covariance \(S=R+G\Omega G^\mathsf{T}\). In particular, the off-diagonal elements of \(\Omega\) contribute to the covariance among observations through \(G\Omega G^\mathsf{T}\).

This result follows because \(G\eta\) has covariance \(G\Omega G^\mathsf{T}\), and independent residual error contributes covariance \(R\). Independent Gaussian terms add their covariance matrices. The resulting FO subject log likelihood is

$$ \ell_{\mathrm{FO}} = -\frac{m}{2}\log(2\pi) -\frac{1}{2}\log|S| -\frac{1}{2}\{y-f(0)\}^\mathsf{T}S^{-1}\{y-f(0)\}. $$

Both the determinant and inverse of \(S\) matter: the determinant normalizes the density, while the inverse weights the residual vector according to its covariance. Equivalently, the same Gaussian integral can be expressed using the random-effect precision. For fixed \(G\) and \(R\), define $$ H=\Omega^{-1}+G^\mathsf{T}R^{-1}G. $$ The determinant identity $$ |R+G\Omega G^\mathsf{T}|=|R|\,|\Omega|\,|H| $$ shows explicitly how the prior determinant and inverse enter a precision-based calculation. This identity follows from \(|I+AB|=|I+BA|\), applied to the matrices in the covariance sum.

Worked Example: A One-Observation FO Likelihood

Consider one hypothetical observation with \(f(0)=10\), observed value \(y=13\), and residual variance \(R=4\). Let the local sensitivity to the two random effects be \(G=(2,1)\), and use the covariance matrix from the preceding example. The variance contributed by random effects is $$ G\Omega G^\mathsf{T} =(2,1)\begin{pmatrix}0.25&0.15\\0.15&0.36\end{pmatrix} \begin{pmatrix}2\\1\end{pmatrix} =4(0.25)+4(0.15)+0.36=1.96. $$ The middle term is the covariance contribution \(2G_1G_2\Omega_{12}\). Thus \(S=4+1.96=5.96\), and the residual is \(13-10=3\). Substitution gives $$ \ell_{\mathrm{FO}} =-\frac12\left[\log(2\pi)+\log(5.96)+\frac{3^2}{5.96}\right] \approx-\frac12[1.8379+1.7851+1.5101] =-2.5665. $$

If the same marginal variances were treated as independent, the random-effect contribution would instead be \(4(0.25)+0.36=1.36\), giving \(S=5.36\). That is a different approximate likelihood, not an equivalent calculation. The example checks the fixed-effects prediction and additive residual assumption by stipulating them directly; it illustrates the local FO calculation rather than claiming a particular data-generating study.

FOCE and Laplace: The Prior Remains Correlated

FOCE uses a subject-specific conditional mode, denoted \(\hat\eta\), and linearizes the prediction at that point. Write \(J\) for the derivative matrix at \(\hat\eta\). The local prediction is \(f(\hat\eta)+J(\eta-\hat\eta)\). To see how the correlated prior enters, combine this linearized likelihood with the same prior \(N(0,\Omega)\). The prior is still centered at zero; centering the linearization at the mode does not replace the prior by a distribution centered there.

Under the stated additive Gaussian residual model, integrating this linearized likelihood against the prior gives the local Gaussian expression with observation covariance \(R+J\Omega J^\mathsf{T}\), and linearized mean \(f(\hat\eta)-J\hat\eta\). The prior precision contributes \(\Omega^{-1}\) to the quadratic form. Implementations and FOCE variants can differ in how they form the approximate subject objective, so the precise convention must be identified; in all cases, a correlated random-effect prior requires its full covariance structure. A conditional linearization should not be confused with Laplace’s approximation, which uses local curvature of the log integrand at its mode.

For Laplace, let \(h(\eta)=\log p(y\mid\eta)+\log p(\eta)\), and suppose \(h\) has an interior mode \(\hat\eta\) with negative-definite Hessian. Define the positive-definite curvature matrix \(H=-\nabla^2h(\hat\eta)\). A second-order Taylor expansion gives \(h(\eta)\approx h(\hat\eta)-\frac12(\eta-\hat\eta)^\mathsf{T}H(\eta-\hat\eta)\). Integrating this local Gaussian yields

$$ \log\int \exp\{h(\eta)\}\,d\eta \approx h(\hat\eta)+\frac{q}{2}\log(2\pi)-\frac12\log|H|. $$

Because the log prior contains \(-\frac12\eta^\mathsf{T}\Omega^{-1}\eta-\frac12\log|\Omega|\), the prior contributes \(\Omega^{-1}\) to \(H\) when the likelihood curvature is added, as well as the separate normalizing term \(-\frac12\log|\Omega|\) inside \(h(\hat\eta)\). Under a locally linear Gaussian likelihood with derivative \(J\), \(H=\Omega^{-1}+J^\mathsf{T}R^{-1}J\). With nonlinear predictions, the likelihood curvature can also include second-derivative terms; it is not generally just \(J^\mathsf{T}R^{-1}J\).

Worked Example: Correlation in a Two-Effect Laplace Curvature

Use the same \(\Omega\), and suppose a hypothetical local Gaussian likelihood has \(J=I\) and \(R=I\), where \(I\) is the two-dimensional identity matrix. Its likelihood information is \(J^\mathsf{T}R^{-1}J=I\), so $$ H=\Omega^{-1}+I = \begin{pmatrix}6.333&-2.222\\-2.222&4.704\end{pmatrix}. $$ The determinant is $$ |H|=(6.333)(4.704)-(-2.222)^2\approx29.79-4.938=24.85. $$

For comparison, the covariance-form determinant identity gives $$ |I+\Omega|=(1.25)(1.36)-(0.15)^2=1.7000-0.0225=1.6775, \qquad |\Omega|\,|H|\approx(0.0675)(24.85)=1.678. $$ The small difference is rounding. The Laplace curvature correction is \(-\frac12\log|H|\approx-1.606\), in addition to the mode’s log joint density and the term \(\frac{q}{2}\log(2\pi)=\log(2\pi)\approx1.838\). This calculation isolates the determinant contribution; it does not assert a value for the full marginal likelihood without specifying the log joint density at the mode.

Checks, Alternatives, and Limitations

A practical check is to verify that \(\Omega\) is symmetric positive definite before evaluating densities or approximations. For the bivariate case, check positive variances and \(|\rho|<1\). In higher dimensions, positive diagonal entries alone are not sufficient; all eigenvalues must be positive. Cholesky factorization is a standard numerical way to check and work with positive-definite covariance matrices without explicitly forming an inverse.

When correlations are near \(1\) or \(-1\), \(|\Omega|\) can be very small and the inverse can have large entries. This can cause unstable determinant calculations, difficult optimization, or a nearly singular curvature matrix. A failed factorization, extreme parameter estimates, or sensitivity to small changes in starting values are warnings to investigate—not evidence that correlation should simply be discarded. Compute log determinants using a Cholesky factor, inspect the estimated correlations and eigenvalues, and verify that covariance and precision calculations use the same parameterization.

The main alternatives differ in where the local approximation is made. FO linearizes at \(\eta=0\); FOCE linearizes at a subject-specific conditional mode; Laplace uses a second-order approximation to the log integrand at that mode. Each must account for the same correlated prior, but their treatment of the nonlinear likelihood differs. None removes the need to check model fit or guarantees that an approximation is accurate when the integrand is strongly non-Gaussian, has multiple important modes, or is poorly identified. Those are limitations of the local approximation, not problems solved merely by adding a correlation parameter.

Common pitfall: Treating the off-diagonal covariance as zero while retaining the marginal variances changes both the joint prior and the induced observation covariance. The correction is to use the full \(\Omega\) in the prior density, its inverse, its determinant, and any propagated covariance such as \(G\Omega G^\mathsf{T}\). Correlation is part of the likelihood calculation, not an optional adjustment applied after it.

Check Your Understanding

Answer each question, then compare with the brief solutions.

  1. For a bivariate random effect, what condition on \(\rho\) ensures a nonsingular covariance matrix when both standard deviations are positive?
  2. With \(G=(1,1)\), what random-effect variance is induced by the covariance matrix in the examples?
  3. In FOCE, does linearizing at \(\hat\eta\) change the mean of the prior distribution? Explain.
  4. What matrix contributes the random-effect prior precision to the Laplace curvature in a locally linear Gaussian likelihood?
  5. Name one diagnostic warning associated with a correlation close to either boundary of its valid range.

Solutions. (1) \(|\rho|<1\), so that \(|\Omega|=\omega_1^2\omega_2^2(1-\rho^2)>0\). (2) \((1,1)\Omega(1,1)^\mathsf{T}=0.25+2(0.15)+0.36=0.91\). (3) No. The prior remains \(N(0,\Omega)\); only the expansion point changes. (4) \(\Omega^{-1}\), added to the likelihood curvature \(J^\mathsf{T}R^{-1}J\) in this case. (5) A nearly singular covariance or curvature matrix may produce failed Cholesky factorization, unstable estimates, or sensitivity to starting values.