Tutorials › Nonlinear Mixed-Effects Models (NLME) › Maintaining Positive-Definite Random-Effect Covariance

The EM and SAEM Algorithms · Tutorial 216 of 797

Maintaining Positive-Definite Random-Effect Covariance

Learn to distinguish positive-semidefinite SAEM statistics from positive-definite covariance estimates, diagnose invalid updates, and use valid parameterizations.

Advanced 11 min read

What You'll Learn

  • State the random-effect covariance assumptions behind a Gaussian SAEM update.
  • Explain why independent elementwise updates can produce an invalid covariance matrix.
  • Prove when a stochastic-approximation update preserves positive semidefiniteness.
  • Use Cholesky factors with positive diagonal entries to represent positive-definite matrices.
  • Diagnose singularity and numerical instability without confusing them with positive definiteness.
  • Compare matrix averaging, Cholesky parameterization, and constrained covariance updates.

Why Covariance Validity Matters

In a nonlinear mixed-effects model, the random-effect covariance describes both the variability of individual effects and their dependence. For a \(q\)-dimensional random effect \(b_i\), the usual Gaussian specification is \(b_i\sim N_q(0,\Omega)\), where \(\Omega\) must be symmetric and positive definite. An update that violates either property is not merely an awkward numerical result: it is not a valid covariance matrix for this model. It can also make likelihood calculations fail, since these typically require \(\Omega^{-1}\) and \(\log|\Omega|\).

The issue in SAEM is subtle. A matrix of accumulated second moments can be positive semidefinite without being positive definite. Furthermore, averaging valid matrices preserves positive semidefiniteness only when the starting matrix is also positive semidefinite and the update uses a common convex weight. Separate updates to matrix entries do not have that guarantee. A reliable implementation must distinguish these facts and ensure that the covariance used in the model remains admissible.

Model and SAEM Covariance Statistic

Definition: A real symmetric matrix \(A\) is positive semidefinite if \(v^{\mathsf T}Av\geq 0\) for every vector \(v\). It is positive definite if \(v^{\mathsf T}Av>0\) for every nonzero vector \(v\). A covariance matrix must be symmetric and positive semidefinite; a nonsingular Gaussian covariance used with an inverse and log determinant must be positive definite.

Assume each subject has a \(q\)-dimensional random effect \(b_i\sim N_q(0,\Omega)\), with \(\Omega\) symmetric positive definite. In the covariance part of the complete-data log likelihood, terms involving \(\Omega\) are proportional to

$$ Q(\Omega)=-\frac{n}{2}\log|\Omega|-\frac{1}{2}\operatorname{tr}\left(\Omega^{-1}\sum_{i=1}^{n}b_i b_i^{\mathsf T}\right). $$

Here \(n\) is the number of subjects. SAEM replaces the unavailable complete-data second moments by a stochastic approximation of the simulated sufficient statistic. Write \(A_k\) for the normalized statistic supplied at iteration \(k\), such as \(n^{-1}\sum_i b_i^{(k)}b_i^{(k)\mathsf T}\) from one simulated draw per subject, and \(S_k\) for its running approximation. The matrix covariance update is then

$$ S_k=(1-\gamma_k)S_{k-1}+\gamma_k A_k,\qquad 0\leq\gamma_k\leq 1. $$

Each outer product \(b_i b_i^{\mathsf T}\) is positive semidefinite because \(v^{\mathsf T}b_i b_i^{\mathsf T}v=(b_i^{\mathsf T}v)^2\geq 0\). Thus averages of these outer products are positive semidefinite. They need not be positive definite: for example, a single draw in two dimensions gives a matrix of rank at most one. When \(S_k\) is positive definite, the covariance M-step sets \(\Omega_k=S_k\).

Why a Matrix Update Can Fail

A covariance matrix is constrained as a whole. Its entries cannot be chosen independently: for a two-dimensional covariance, the squared covariance must not exceed the product of the two variances. Updating diagonal entries and an off-diagonal entry with unrelated gains can break this constraint even if both the old matrix and the new matrix of proposed entries were intended to represent covariances.

Worked Example: Separate Entry Updates Become Invalid

Suppose the starting covariance is \(\Omega_0=\begin{pmatrix}1&0.9\\0.9&1\end{pmatrix}\). It is positive definite: its determinant is \(1-0.9^2=0.19>0\), and its diagonal entries are positive. A valid target statistic is \(A=\begin{pmatrix}0.01&0\\0&1\end{pmatrix}\), also positive definite.

If a routine updates the first variance with gain \(0.9\), leaves the second variance unchanged, and leaves the covariance unchanged, its result is

$$ \begin{pmatrix} (1-0.9)(1)+0.9(0.01)&0.9\\ 0.9&1 \end{pmatrix} = \begin{pmatrix} 0.109&0.9\\ 0.9&1 \end{pmatrix}. $$

The determinant is \(0.109(1)-0.9^2=0.109-0.81=-0.701\), so the result is not positive definite (indeed, it is not positive semidefinite). The failure came from using different update rules for entries, not from either endpoint matrix. A single common gain applied to the whole matrix would instead produce a convex combination of the two valid endpoint matrices.

When Matrix Averaging Preserves Validity

The relevant guarantee is about positive semidefiniteness, and it has an essential initialization condition. If \(S_{k-1}\) and \(A_k\) are both positive semidefinite and \(0\leq\gamma_k\leq1\), then their common-weight update remains positive semidefinite. It is not enough that \(A_k\) is positive semidefinite: the starting statistic must be as well.

Result: If \(S_0\) is positive semidefinite, every \(A_k\) is positive semidefinite, and each gain satisfies \(0\leq\gamma_k\leq1\), then every recursively defined \(S_k=(1-\gamma_k)S_{k-1}+\gamma_k A_k\) is positive semidefinite. If \(S_{k-1}\) is positive definite and \(0\leq\gamma_k<1\), the update is positive definite, even when \(A_k\) is only positive semidefinite.

For the first claim, take any vector \(v\). By the assumptions,

$$ v^{\mathsf T}S_kv=(1-\gamma_k)v^{\mathsf T}S_{k-1}v+ \gamma_k v^{\mathsf T}A_kv\geq0. $$

The result follows by induction from \(S_0\). For the stronger claim, if \(v\neq0\), then \(v^{\mathsf T}S_{k-1}v>0\). Since \(1-\gamma_k>0\) and the other quadratic form is nonnegative, \(v^{\mathsf T}S_kv>0\). At \(\gamma_k=1\), the update equals \(A_k\), which may be singular. This distinction explains why a positive-semidefinite SA statistic does not automatically give a positive-definite covariance at every iteration.

Worked Example: A Common-Gain Update

Let \(S_0=\begin{pmatrix}1&0.2\\0.2&1\end{pmatrix}\) and let a simulated second-moment statistic be \(A_1=\begin{pmatrix}4&2\\2&1\end{pmatrix}\). The first matrix has determinant \(0.96>0\) and is positive definite. The second is positive semidefinite because it is \(\begin{pmatrix}2\\1\end{pmatrix}\begin{pmatrix}2&1\end{pmatrix}\). With \(\gamma_1=0.5\),

$$ S_1=0.5S_0+0.5A_1 =\begin{pmatrix}2.5&1.1\\1.1&1\end{pmatrix}. $$

Its determinant is \(2.5(1)-1.1^2=2.5-1.21=1.29>0\), with positive diagonal entries, so it is positive definite. The positive definiteness also follows from the result above: the old statistic is positive definite and the gain is strictly less than one. If instead \(\gamma_1=1\), then \(S_1=A_1\), which has determinant zero and is only positive semidefinite.

Cholesky Parameterization

A direct way to represent a positive-definite covariance is through its Cholesky factor. Every symmetric positive-definite \(\Omega\) has a unique factorization \(\Omega=LL^{\mathsf T}\), where \(L\) is lower triangular and has strictly positive diagonal entries. Conversely, every such \(L\) gives a positive-definite matrix: for nonzero \(v\), \(v^{\mathsf T}LL^{\mathsf T}v=\|L^{\mathsf T}v\|^2>0\), since \(L\) is invertible.

For unconstrained optimization over factor entries, write each diagonal entry as an exponential, \(L_{jj}=\exp(\eta_j)\), and leave the entries below the diagonal unconstrained. Any finite \(\eta_j\) gives a strictly positive diagonal entry. The transformed objective can then be optimized in the unconstrained coordinates \(\eta_j\) and \(L_{ij}\) for \(i>j\), while \(\Omega=LL^{\mathsf T}\) stays positive definite at each evaluation.

Worked Example: Building a Valid Covariance From a Factor

For two random effects, choose \(L=\begin{pmatrix}0.3&0\\0.12&0.4\end{pmatrix}\). Its diagonal entries are positive, so it is invertible. Multiplication gives

$$ \Omega=LL^{\mathsf T} = \begin{pmatrix} 0.09&0.036\\ 0.036&0.1744 \end{pmatrix}. $$

The determinant is \(0.09(0.1744)-0.036^2=0.015696-0.001296=0.0144>0\), and the first diagonal entry is positive, confirming positive definiteness. If the diagonal entries of \(L\) are represented as exponentials, the values here correspond to \(\eta_1=\log(0.3)\) and \(\eta_2=\log(0.4)\); the lower off-diagonal entry is \(0.12\). The resulting covariance has variances \(0.09\) and \(0.1744\), and covariance \(0.036\), in the appropriate squared and product units of the random effects.

Using the Parameterization in SAEM

There are two related but distinct operations. SAEM commonly smooths sufficient statistics using the matrix recursion above, then performs an M-step. When the smoothed second-moment statistic is positive definite, the Gaussian covariance M-step is its value. Alternatively, an implementation can optimize the covariance-dependent objective in Cholesky coordinates, ensuring that every trial covariance is positive definite. Reparameterizing the M-step does not mean that one can average Cholesky factors with the usual matrix-statistic gain and obtain the same SAEM update: the map \(L\mapsto LL^{\mathsf T}\) is nonlinear, and factor averaging does not generally equal covariance averaging.

A short justification for the covariance M-step clarifies the boundary case. Let \(S=n^{-1}\sum_i b_i b_i^{\mathsf T}\) be the normalized second moment. Apart from a positive multiplier, maximizing the Gaussian objective is equivalent to maximizing \(-\log|\Omega|-\operatorname{tr}(\Omega^{-1}S)\). Its matrix derivative with respect to symmetric \(\Omega\) is \(-\Omega^{-1}+\Omega^{-1}S\Omega^{-1}\). Setting this to zero and multiplying on the left and right by \(\Omega\) gives \(S=\Omega\). This is an interior positive-definite solution when \(S\) is positive definite. If \(S\) is singular, that interior solution is unavailable; forcing a positive-definite answer requires a constrained or regularized procedure, not simply declaring the singular moment matrix positive definite.

One common safeguard is a lower bound on Cholesky diagonal entries, or an eigenvalue floor such as replacing an estimated matrix's eigenvalues below a chosen threshold with that threshold. Another is to use \(\Omega=LL^{\mathsf T}+\epsilon I\) for fixed \(\epsilon>0\). Each enforces positive definiteness, but imposes a constraint or changes the covariance estimate; it is not an exact unconstrained Gaussian M-step. The threshold should be chosen in relation to parameter scales, reported, and checked for sensitivity.

Diagnostics, Alternatives, and Limitations

Check covariance validity at the point where it is constructed and before computing its inverse or log determinant. Useful diagnostics include symmetry error, the smallest eigenvalue, Cholesky-factorization success, and the condition number. A matrix can be positive definite but nearly singular, creating unstable inverses and unreliable numerical optimization. Conversely, a small negative eigenvalue on the order of floating-point error may reflect rounding; symmetrizing with \((\Omega+\Omega^{\mathsf T})/2\) addresses asymmetry but does not by itself ensure positive definiteness.

ApproachValidity propertyMain caution
Common-gain matrix averagingPreserves positive semidefiniteness if the initial matrix and every new statistic are positive semidefinite and gains lie in [0, 1].Positive semidefiniteness does not ensure invertibility; full-gain updates can be singular.
Cholesky coordinatesStrictly positive diagonal factor entries guarantee a positive-definite covariance.Factor-coordinate optimization can be poorly scaled, and factor averaging is not the standard covariance-statistic update.
Eigenvalue floor or diagonal loadingCan keep the matrix away from singularity when implemented with a positive floor.Imposes a constraint or alters the estimate; results can depend on the chosen floor.

If an update fails, trace the complete operation rather than clipping a reported correlation alone. Confirm that the sufficient statistic was formed from outer products consistently, the initial statistic was valid, a single gain was applied to the whole matrix, and no entrywise rounding or scaling changed the matrix. When a Cholesky factorization fails, inspect the eigenvalues and units; an arbitrary diagonal addition may conceal a coding error or materially change a variance estimate. Cholesky parameterization also cannot eliminate weak information in the data: it ensures admissibility, not accurate estimation, good mixing, or well-conditioned curvature.

Common Mistake

Common mistake: “Every new SAEM statistic is positive semidefinite, so the running statistic must be positive semidefinite.” This omits the initial condition. For example, \(S_0=-I\), \(A_1=0\), and \(\gamma_1=0.25\) give \(S_1=-0.75I\), which is not positive semidefinite. The correct guarantee requires both \(S_0\) and every \(A_k\) to be positive semidefinite, along with \(0\leq\gamma_k\leq1\). Even then, the guarantee is only positive semidefiniteness; strict positive definiteness needs an additional condition or a valid constrained parameterization.

Check Your Understanding

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

  1. What conditions on the starting statistic, new statistics, and gain ensure that a common-gain SA update remains positive semidefinite?
  2. A positive-definite starting statistic is updated with a positive-semidefinite statistic using \(\gamma=0.4\). Must the result be positive definite? Why?
  3. Why can a Cholesky factor with positive diagonal entries not represent a singular covariance exactly?
  4. What is the main statistical caution when adding \(\epsilon I\) to repair a nearly singular covariance?

Solutions. (1) \(S_0\) and every \(A_k\) must be positive semidefinite, and each common gain must satisfy \(0\leq\gamma_k\leq1\); the quadratic-form argument establishes the result at each step. (2) Yes. Since \(1-\gamma=0.6>0\), every nonzero vector has a strictly positive quadratic form contribution from the old positive-definite matrix, while the new statistic contributes a nonnegative amount. (3) A triangular factor with strictly positive diagonal is invertible, so \(LL^{\mathsf T}\) is positive definite and has positive determinant; a singular matrix has determinant zero. (4) The addition changes the covariance estimate or imposes a lower-bound constraint. Its magnitude should be justified and sensitivity to it assessed, rather than treated as a numerically neutral correction.