Tutorials › Generalized Linear Mixed Models (GLMM) › Covariance Parameterization and Numerical Stability

Convergence, Singular Fits and Boundary Estimates · Tutorial 299 of 698

Covariance Parameterization and Numerical Stability

You will learn how Cholesky parameterizations keep estimated random-effects covariance matrices valid and how to recognize numerical problems associated with their components.

Advanced 12 min read

What You'll Learn

  • Write a random-effects covariance matrix as a Cholesky factor times its transpose.
  • Explain why positive Cholesky diagonal entries guarantee a positive-definite covariance matrix.
  • Convert between Cholesky entries, variances, standard deviations, and correlations.
  • Distinguish Cholesky coordinates from direct covariance or standard-deviation/correlation coordinates.
  • Diagnose scale-related numerical difficulty and describe how predictor rescaling changes covariance coordinates.
  • Identify limitations of the Cholesky parameterization and practical checks for an estimated fit.

Why Parameterize a Covariance Matrix?

In a generalized linear mixed model, random effects represent group-specific departures from the fixed-effects structure. Their covariance matrix determines how those departures vary and co-vary. Estimation is therefore not just a search for numerical values: every candidate covariance matrix must be mathematically admissible. In particular, a covariance matrix must be symmetric and positive semidefinite. A parameterization that produces invalid matrices can cause an optimizer to spend effort outside the model’s allowable parameter space.

The Cholesky parameterization addresses this constraint by expressing a positive-definite covariance matrix as a product of a lower-triangular matrix and its transpose. This gives the optimizer coordinates that generate valid matrices throughout the interior of the parameter space. It does not, by itself, guarantee that the likelihood is well behaved or that the estimated components are numerically stable. Those questions still require diagnostics.

Definition: Suppose the random-effects vector for group \(j\) is \(b_j\), with \(q\) components. In a GLMM, a common assumption is that the group random effects are independent across groups and satisfy \(b_j \sim N_q(0,G)\), where \(G\) is a symmetric \(q \times q\) covariance matrix. A Cholesky parameterization writes \(G=LL^\mathsf{T}\), where \(L\) is a lower-triangular matrix. If the diagonal entries of \(L\) are positive, then \(G\) is positive definite.

For example, with a random intercept and a random slope, one group’s linear predictor may contain \(b_{0j}+b_{1j}x_{ij}\). The vector \(b_j=(b_{0j},b_{1j})^\mathsf{T}\) has a two-by-two covariance matrix. The response distribution is specified conditional on the random effects, and observations are ordinarily assumed conditionally independent given those effects and the covariates. The Cholesky factor concerns the distribution of the random effects; it does not change the chosen response distribution or link function.

How the Factor Guarantees Validity

For two random effects, write the lower-triangular factor as \(L\). Multiplying \(L\) by its transpose gives the covariance entries directly:

$$ L= \begin{pmatrix} a & 0\\ c & d \end{pmatrix}, \qquad G=LL^\mathsf{T} = \begin{pmatrix} a^2 & ac\\ ac & c^2+d^2 \end{pmatrix}. $$

The matrix is symmetric by construction. Its first diagonal entry is \(a^2\), and its second is \(c^2+d^2\), so both are nonnegative. More importantly, its determinant is \(a^2d^2\). If \(a>0\) and \(d>0\), then both diagonal entries and the determinant are positive, which makes this two-by-two symmetric matrix positive definite. The same argument extends to \(q\) dimensions: for any nonzero vector \(v\),

$$ v^\mathsf{T}Gv =v^\mathsf{T}LL^\mathsf{T}v =(L^\mathsf{T}v)^\mathsf{T}(L^\mathsf{T}v) =\lVert L^\mathsf{T}v\rVert^2>0, $$

because a triangular \(L\) with nonzero diagonal is invertible, so \(L^\mathsf{T}v\ne 0\). Thus the product representation guarantees positive definiteness when the factor has a nonzero diagonal. This is a validity result, not a guarantee that the data identify every covariance component well.

A frequent optimization convention is to set each diagonal entry to an exponential, such as \(a=\exp(\eta_1)\) and \(d=\exp(\eta_2)\), while leaving the off-diagonal entry \(c\) unconstrained. This allows the optimizer to work with unrestricted real-valued coordinates \(\eta_1,\eta_2,c\), while ensuring that \(a,d>0\). Implementations may use a scaled version of this construction or a different internal convention, so reported optimizer parameters need not equal the displayed entries of \(L\).

Worked Example: Recovering Variances and Correlation

Suppose a hypothetical logistic GLMM has a random intercept and a random slope for a predictor measured in units of 10. Suppose the fitted Cholesky factor, in that order, is \(L=\begin{pmatrix}0.8&0\\0.3&0.6\end{pmatrix}\). The intercept is on the log-odds scale, and the slope is change in log odds per 10 predictor units.

First calculate \(G=LL^\mathsf{T}\):

$$ G= \begin{pmatrix} 0.8^2 & 0.8(0.3)\\ 0.8(0.3) & 0.3^2+0.6^2 \end{pmatrix} = \begin{pmatrix} 0.64 & 0.24\\ 0.24 & 0.45 \end{pmatrix}. $$

The estimated random-intercept variance is \(0.64\), and the random-slope variance is \(0.45\). Their standard deviations are \(\sqrt{0.64}=0.800\) log-odds units and \(\sqrt{0.45}\approx0.671\) log-odds per 10 predictor units, respectively. The covariance is \(0.24\), in the product of those units. The correlation is \[ 0.24\big/\{\sqrt{0.64}\sqrt{0.45}\} \approx 0.447. \] The determinant is \(0.64(0.45)-0.24^2=0.2304>0\), consistent with a positive-definite matrix. The positive covariance means that groups with higher-than-average random intercepts tend, under this fitted model, also to have higher-than-average random slopes.

Cholesky Coordinates Are Not Correlations

The entries of \(L\) are computational coordinates. Except in special cases, they are not the standard deviations, variances, or correlations that researchers usually report. For a two-dimensional random effect with standard deviations \(\sigma_1,\sigma_2\) and correlation \(\rho\), one valid Cholesky factor is

$$ L= \begin{pmatrix} \sigma_1 & 0\\ \rho\sigma_2 & \sigma_2\sqrt{1-\rho^2} \end{pmatrix}, \qquad -1<\rho<1. $$

Multiplication gives diagonal entries \(\sigma_1^2\) and \(\sigma_2^2\), and off-diagonal entry \(\rho\sigma_1\sigma_2\). Notice that \(L_{21}=\rho\sigma_2\), not \(\rho\), and \(L_{22}\) is not generally \(\sigma_2\). In dimensions above two, the relationship between a Cholesky factor and the resulting correlations is more involved still.

Worked Example: Constructing a Factor From Standard Deviations and Correlation

Consider hypothetical random effects with standard deviations \(0.50\) and \(0.40\), and correlation \(-0.60\). The factor entries are

$$ L_{11}=0.50,\qquad L_{21}=(-0.60)(0.40)=-0.24,\qquad L_{22}=0.40\sqrt{1-(-0.60)^2}=0.40(0.80)=0.32. $$

Therefore,

$$ LL^\mathsf{T} = \begin{pmatrix} 0.50^2 & 0.50(-0.24)\\ 0.50(-0.24) & (-0.24)^2+0.32^2 \end{pmatrix} = \begin{pmatrix} 0.25 & -0.12\\ -0.12 & 0.16 \end{pmatrix}. $$

The covariance is \(-0.12=(-0.60)(0.50)(0.40)\), and dividing it by the product of the standard deviations returns the correlation \(-0.60\). The diagonal entries of \(L\) are \(0.50\) and \(0.32\); the second is not the second random-effect standard deviation.

When fitting by maximum likelihood, re-expressing the covariance parameters in Cholesky coordinates does not add a Jacobian term to the likelihood. The likelihood is evaluated at the covariance matrix generated by the current optimizer coordinates. A Jacobian is relevant when transforming a probability density on parameters, as in a Bayesian prior transformation; that is a different calculation from maximizing the likelihood over a reparameterized model.

Scaling, Conditioning, and Diagnostics

A valid matrix can still be numerically awkward. Random-intercept and random-slope components often have different units and magnitudes, especially when the predictor is recorded on a large scale. The resulting covariance coordinates can differ greatly in size. This can make numerical optimization less well scaled and make small changes in one component difficult to compare with changes in another. Scaling the predictor changes the units and numerical values of the slope component; it does not change the underlying fitted linear predictor when the coefficients are transformed consistently.

Worked Example: Rescaling a Random-Slope Predictor

Suppose a hypothetical model uses predictor \(x\), measured in units from 0 to 1000. Its random intercept has standard deviation \(0.50\), its random slope per one unit of \(x\) has standard deviation \(0.005\), and their correlation is \(0.40\). The covariance matrix is

$$ G_{(b_0,b_1)} = \begin{pmatrix} 0.50^2 & 0.40(0.50)(0.005)\\ 0.40(0.50)(0.005) & 0.005^2 \end{pmatrix} = \begin{pmatrix} 0.25 & 0.001\\ 0.001 & 0.000025 \end{pmatrix}. $$

Now define \(z=x/100\), so \(x=100z\). The same random contribution can be written \(b_0+b_1x=b_0+(100b_1)z\). Thus the slope coefficient on the \(z\) scale is \(c_1=100b_1\). Its standard deviation is \(100(0.005)=0.50\), its covariance with the intercept is \(100(0.001)=0.10\), and its variance is \(10000(0.000025)=0.25\). The transformed covariance matrix is

$$ G_{(b_0,c_1)} = \begin{pmatrix} 0.25 & 0.10\\ 0.10 & 0.25 \end{pmatrix}. $$

The correlation remains \(0.40\), and the group-specific linear predictors are unchanged. The entries are now on more comparable scales, which can make optimization better scaled. Rescaling cannot create information absent from the data, and it does not guarantee convergence; it is a targeted numerical adjustment, not proof that the fitted covariance is reliable.

Useful checks include confirming that the reported covariance matrix is symmetric, recalculating its standard deviations and correlations from its entries, and checking that its entries agree with the fitted factor under the software’s stated convention. Compare results across sensible predictor scales or equivalent parameterizations when numerical behavior is concerning. Also examine the convergence message, scaled gradient, Hessian, and optimizer sensitivity using the corresponding diagnostics. A convergence flag alone does not establish that every component is accurately estimated.

1
Identify the coordinates.
Determine whether the software reports a covariance matrix, standard deviations and correlations, or Cholesky-factor parameters. Do not interpret factor entries as correlations without conversion.
2
Check the matrix reconstruction.
Form \(LL^\mathsf{T}\) using the documented ordering and scaling. Compare the result with the reported variances and covariances.
3
Assess numerical scale.
Check whether random-slope units or predictor magnitudes make covariance components very different in size. Consider a scientifically interpretable rescaling and refit.
4
Review the fit diagnostics.
Check convergence information and curvature diagnostics, and determine whether equivalent fits give materially similar estimates. A valid Cholesky factor does not rule out weak information or numerical instability.

Choices and Limitations

Directly optimizing all covariance entries is easy to describe, but arbitrary entries need not produce a positive-semidefinite matrix. Constraints can be added, but they are themselves a numerical problem. A standard-deviation-and-correlation parameterization is often easier to interpret, but it also requires constraints: standard deviations must be nonnegative and the correlation structure must be valid. The Cholesky representation enforces positive definiteness through its factor structure and is consequently a common computational choice.

The choice is not cost-free. Cholesky entries depend on the ordering of the random effects, and their magnitudes depend on the units used. They are useful for computation but are usually less directly interpretable than variances, standard deviations, and correlations. Further, strictly positive diagonal entries represent positive-definite matrices in the interior; they do not represent every positive-semidefinite matrix exactly. A Cholesky parameterization therefore ensures validity of generated matrices, not adequate data support, good conditioning, or a scientifically appropriate random-effects structure.

Common pitfall: “The optimizer used unconstrained Cholesky parameters, so the covariance estimates must be numerically trustworthy.” The factorization guarantees a valid positive-definite matrix for positive diagonal entries, but it does not guarantee stable estimates or a well-behaved likelihood. Reconstruct the covariance matrix, verify units and scaling, and assess convergence and curvature diagnostics before interpreting its components.

Check Your Understanding

Answer each question, then compare with the brief solutions.

  1. For \(L=\begin{pmatrix}0.6&0\\0.2&0.5\end{pmatrix}\), calculate \(G=LL^\mathsf{T}\), its two standard deviations, and the correlation.
  2. Why does a lower-triangular factor with positive diagonal entries produce a positive-definite covariance matrix?
  3. If a predictor is replaced by \(z=x/10\), how does the random-slope coefficient change so that the linear predictor stays the same?
  4. Does a Cholesky parameterization guarantee that covariance components are well estimated? Give one reason.

Solutions. (1) \(G=\begin{pmatrix}0.36&0.12\\0.12&0.29\end{pmatrix}\); the standard deviations are \(0.600\) and \(\sqrt{0.29}\approx0.539\), and the correlation is \(0.12/(0.600\sqrt{0.29})\approx0.372\). (2) For nonzero \(v\), \(v^\mathsf{T}LL^\mathsf{T}v=\lVert L^\mathsf{T}v\rVert^2>0\), since the factor is invertible. (3) Since \(x=10z\), the coefficient on \(z\) must be \(10b_1\). (4) No. It guarantees a valid positive-definite matrix, but the data may provide weak information about components, or the optimization may still be poorly conditioned.

Clinical Biostats