Tutorials › Population Pharmacokinetics › Sampling Correlated Random Effects for Virtual Subjects

Simulation for Dose Justification · Tutorial 462 of 599

Sampling Correlated Random Effects for Virtual Subjects

You will learn to generate virtual-subject random effects that preserve the estimated covariance among PK parameters, and to check whether the resulting draws match the intended joint distribution.

Advanced 10 min read

What You'll Learn

  • Specify a multivariate distribution for interindividual random effects.
  • Convert an estimated covariance matrix into correlated draws using a Cholesky factor.
  • Check generated sample means, variances, and correlations against their targets.
  • Recognize how independent sampling changes the intended population model.
  • Handle positive-semidefinite covariance matrices and diagnose invalid inputs.

Why the Joint Distribution Matters

When a population PK model assigns interindividual variability to more than one parameter, a virtual subject is defined by a joint set of random effects, not by a collection of unrelated draws. For example, clearance and volume random effects may be negatively correlated. Drawing them independently preserves each parameter's marginal spread but removes the modeled tendency for subjects with a higher clearance effect to have a lower volume effect. That can change the simulated distribution of concentrations and exposure.

The earlier material on simulating individual profiles describes how sampled individual parameters are used to generate concentration-time profiles. Here the focus is narrower: how to sample the interindividual random effects that determine those parameters, while preserving their estimated covariance.

Definition: Let \(\boldsymbol{\eta}_i=(\eta_{i1},\ldots,\eta_{ip})^\mathsf{T}\) be the vector of interindividual random effects for virtual subject \(i\). Under a multivariate normal random-effects model, \(\boldsymbol{\eta}_i\sim N(\mathbf{0},\Omega)\), where \(\Omega\) is the \(p\times p\) covariance matrix. Its diagonal elements are the random-effect variances, and its off-diagonal elements are covariances. The correlation between effects \(j\) and \(k\) is \(\Omega_{jk}/\sqrt{\Omega_{jj}\Omega_{kk}}\), when both variances are positive.

The distribution is specified on the random-effects scale used by the model. For instance, in a log-normal parameter model, a typical individual clearance may be written \(CL_i=CL_{\mathrm{typ}}\exp(\eta_{i,CL})\). The covariance in \(\Omega\) is then on the \(\eta\) scale; it is not the covariance of clearance values measured in physical units. A simulated \(\boldsymbol{\eta}_i\) is transformed through the model's parameter equations before the profile is calculated.

The usual model has mean-zero random effects, and independent subjects receive independent draws from the same joint distribution. The random effects within each subject are generally not independent unless the corresponding covariances in \(\Omega\) are zero. In this tutorial, \(\Omega\) is treated as fixed at its estimated value. Sampling uncertainty in that estimate is a separate issue.

Generating Correlated Draws

A standard construction begins with independent standard normal variables and applies a matrix transformation. Suppose \(\Omega\) is positive definite and has Cholesky factor \(L\), so that \(\Omega=LL^\mathsf{T}\), with \(L\) lower triangular. Draw a vector \(\mathbf{z}_i\) whose components are independent \(N(0,1)\) variables, then set \(\boldsymbol{\eta}_i=L\mathbf{z}_i\).

$$ \mathbf{z}_i\sim N(\mathbf{0},I),\qquad \boldsymbol{\eta}_i=L\mathbf{z}_i,\qquad LL^\mathsf{T}=\Omega $$

This construction gives the desired mean and covariance. Since \(E(\mathbf{z}_i)=\mathbf{0}\), linearity of expectation gives \(E(\boldsymbol{\eta}_i)=L\mathbf{0}=\mathbf{0}\). Using the covariance of a linear transformation,

$$ \operatorname{Cov}(\boldsymbol{\eta}_i) =\operatorname{Cov}(L\mathbf{z}_i) =L\operatorname{Cov}(\mathbf{z}_i)L^\mathsf{T} =LIL^\mathsf{T} =LL^\mathsf{T} =\Omega. $$

Thus the factor does not merely create effects with the right marginal variances: it creates the full covariance matrix. The same construction can be written using a standard normal vector \(\mathbf{z}_i\) and any matrix \(A\) satisfying \(AA^\mathsf{T}=\Omega\); the Cholesky factor is a convenient, widely used choice when the matrix is positive definite.

Worked Example: Drawing Correlated Clearance and Volume Effects

Suppose a hypothetical fitted model has two random effects, \(\eta_{i,CL}\) and \(\eta_{i,V}\), with standard deviations \(0.30\) and \(0.20\), and correlation \(-0.60\). These effects are dimensionless log-scale deviations.

First convert the standard deviations and correlation into a covariance matrix. The variances are \(0.30^2=0.09\) and \(0.20^2=0.04\). The covariance is \((-0.60)(0.30)(0.20)=-0.036\). Therefore,

$$ \Omega= \begin{pmatrix} 0.09 & -0.036\\ -0.036 & 0.04 \end{pmatrix}. $$

A Cholesky factor is

$$ L= \begin{pmatrix} 0.30 & 0\\ -0.12 & 0.16 \end{pmatrix}, \qquad LL^\mathsf{T}= \begin{pmatrix} 0.09 & -0.036\\ -0.036 & 0.0144+0.0256 \end{pmatrix} =\Omega. $$

For one hypothetical draw, let \(\mathbf{z}_i=(1,-0.5)^\mathsf{T}\). Then

$$ \boldsymbol{\eta}_i=L\mathbf{z}_i = \begin{pmatrix} 0.30(1)+0(-0.5)\\ -0.12(1)+0.16(-0.5) \end{pmatrix} = \begin{pmatrix} 0.30\\ -0.20 \end{pmatrix}. $$

If the model uses \(CL_i=CL_{\mathrm{typ}}\exp(\eta_{i,CL})\) and \(V_i=V_{\mathrm{typ}}\exp(\eta_{i,V})\), this draw gives \(CL_i/CL_{\mathrm{typ}}=\exp(0.30)\approx1.350\) and \(V_i/V_{\mathrm{typ}}=\exp(-0.20)\approx0.8187\). These are individual parameter multipliers; the random effects themselves remain the values \(0.30\) and \(-0.20\).

Implementation and Checks

For each virtual subject, generate a fresh vector of independent standard normal values, multiply by the same factor \(L\), and use the resulting random-effects vector in the model. The following sequence makes the key operations explicit.

1
Check the parameter order.
Write down which random effect occupies each row and column of \(\Omega\), and use that same order in \(\mathbf{z}_i\), \(L\), and the model equations.
2
Check the covariance matrix.
Confirm that \(\Omega\) is symmetric and has nonnegative variances. For a valid covariance matrix, it must also be positive semidefinite.
3
Factor the matrix.
For a positive-definite \(\Omega\), calculate a Cholesky factor \(L\) such that \(LL^\mathsf{T}=\Omega\).
4
Generate and transform.
For each subject, draw independent standard normal components and compute \(\boldsymbol{\eta}_i=L\mathbf{z}_i\). Apply these effects using the model's specified parameterization.
5
Validate the draws.
Across a sufficiently large set of generated subjects, compare the empirical means, variances, and correlations with zero and the corresponding entries of \(\Omega\).

The empirical values will not exactly equal their targets in a finite simulation. They should be close enough to be plausible given the simulation size; a discrepancy that remains large when the number of subjects increases suggests an implementation problem. It is useful to inspect the covariance matrix and the correlation matrix, because a covariance's magnitude depends on the scales of its two effects. Also check whether the simulated marginal distributions and parameter transformations behave sensibly—for example, whether a log-scale transformation produces plausible positive parameter values.

Worked Example: Detecting the Independent-Sampling Error

Use the hypothetical covariance matrix from the previous example. Its target correlation is

$$ \frac{-0.036}{\sqrt{0.09(0.04)}}= \frac{-0.036}{0.06}=-0.60. $$

A mistaken implementation draws \(\eta_{i,CL}=0.30z_{i1}\) and \(\eta_{i,V}=0.20z_{i2}\), using independent standard normal variables \(z_{i1}\) and \(z_{i2}\). The marginal variances are still correct: \(0.30^2=0.09\) and \(0.20^2=0.04\). But independence implies

$$ \operatorname{Cov}(\eta_{i,CL},\eta_{i,V}) =0.30(0.20)\operatorname{Cov}(z_{i1},z_{i2})=0, $$

so the generated correlation is zero, not \(-0.60\). For example, with \((z_{i1},z_{i2})=(1,-0.5)\), this incorrect method gives \((0.30,-0.10)\), whereas the correlated construction gives \((0.30,-0.20)\). The difference for one draw does not establish the population correlation; the covariance calculation does. Across many draws, the incorrect method will reproduce the marginal spreads but not the intended joint distribution.

This error matters because the model uses combinations of parameters to determine a profile. A population with the correct marginal clearance and volume distributions but the wrong dependence between them is a different simulated population. Any resulting exposure summaries describe that altered population, not the one specified by the fitted model.

Valid Matrices and Edge Cases

A covariance matrix must be symmetric and positive semidefinite: for every vector \(\mathbf{a}\), \(\mathbf{a}^\mathsf{T}\Omega\mathbf{a}\geq0\). A positive-definite matrix gives a conventional Cholesky factor with strictly positive diagonal entries. A positive-semidefinite matrix can be singular, so a standard Cholesky routine may fail even though the matrix is mathematically valid. This can arise, for example, when two effects are perfectly correlated or when numerical estimation produces a zero-variance direction.

A singular covariance matrix can be handled by a factorization suited to positive-semidefinite matrices, such as an eigenvalue decomposition. If \(\Omega=Q\Lambda Q^\mathsf{T}\), with nonnegative eigenvalues on the diagonal of \(\Lambda\), then \(A=Q\Lambda^{1/2}\) satisfies \(AA^\mathsf{T}=\Omega\); use \(\boldsymbol{\eta}_i=A\mathbf{z}_i\). A small negative eigenvalue caused only by numerical rounding may require careful numerical treatment, but a materially negative eigenvalue indicates an invalid matrix, not a harmless factorization inconvenience. Do not silently replace a problematic covariance matrix with a diagonal one: that changes the model.

Worked Example: Sampling a Singular but Valid Covariance Matrix

Consider the hypothetical matrix

$$ \Omega= \begin{pmatrix} 0.04 & 0.04\\ 0.04 & 0.04 \end{pmatrix}. $$

Both effects have variance \(0.04\), and their correlation is \(0.04/\sqrt{0.04(0.04)}=1\). The matrix is positive semidefinite but singular: its determinant is \(0.04(0.04)-0.04^2=0\). One valid factor is

$$ A= \begin{pmatrix} 0.20 & 0\\ 0.20 & 0 \end{pmatrix}, \qquad AA^\mathsf{T}=\Omega. $$

For \(\mathbf{z}_i=(0.5,-1)^\mathsf{T}\), the draw is

$$ \boldsymbol{\eta}_i=A\mathbf{z}_i= \begin{pmatrix} 0.20(0.5)\\ 0.20(0.5) \end{pmatrix} = \begin{pmatrix} 0.10\\ 0.10 \end{pmatrix}. $$

The second standard normal component has no effect because this covariance matrix has only one variable direction. Every generated pair has equal components, as required by perfect correlation. This example also shows why a routine that insists on a strictly positive Cholesky diagonal may reject a valid, singular covariance matrix.

Alternatives, Diagnostics, and Limitations

Independent normal draws are appropriate only when the intended covariance matrix is diagonal. They are easy to implement, but using them for a non-diagonal estimate discards parameter compensation encoded by the fitted model. A second approach is to use a multivariate-normal random-number routine that accepts a covariance matrix directly. This can be convenient, but the user must still supply the correct parameter order and confirm that the routine interprets the input as a covariance matrix rather than a standard-deviation or correlation matrix. The factor-and-transform construction makes the dependence structure visible and is straightforward to audit.

The multivariate normal model is an assumption, not a guarantee that every estimated random-effects distribution is adequately represented by a normal distribution. Earlier work on heavy-tailed effects and subpopulation mixtures highlights possible departures from a single normal population. If those features are supported by the model or data, sampling from a single multivariate normal distribution may not represent the intended population. The simulation must reflect the selected model rather than imposing normality simply because a Cholesky procedure is convenient.

Common warning signs include an asymmetric or incorrectly ordered matrix, a factor that does not reconstruct \(\Omega\), generated correlations near zero when the target is nonzero, or simulated variances that systematically disagree with the diagonal entries. A frequent mistake is to put standard deviations on the diagonal of \(\Omega\) instead of variances. Another is to enter a correlation matrix where the software expects a covariance matrix. Check the units and scale of every entry, and verify \(LL^\mathsf{T}=\Omega\) numerically before generating a cohort.

Key takeaway: To preserve estimated dependence, draw independent standard normal components and transform them with a factor \(L\) satisfying \(LL^\mathsf{T}=\Omega\). Confirm the parameter ordering, matrix validity, and empirical covariance of the generated effects before using them in PK simulations.

Check Your Understanding

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

  1. For two effects with standard deviations \(0.25\) and \(0.40\), and correlation \(0.50\), what is their covariance?
  2. Why does multiplying independent standard normal draws only by the marginal standard deviations fail to preserve a nonzero target correlation?
  3. If \(L\) satisfies \(LL^\mathsf{T}=\Omega\) and \(\operatorname{Cov}(\mathbf{z})=I\), what is \(\operatorname{Cov}(L\mathbf{z})\)?
  4. What does a singular covariance matrix imply about the random-effect draws, and does singularity alone make the matrix invalid?
  5. Name two checks that can help detect an incorrectly implemented correlated-effects simulation.

Solutions. (1) The covariance is \(0.50(0.25)(0.40)=0.0500\). (2) Independent components have covariance zero, so scaling them preserves zero covariance rather than creating the target dependence. (3) \(\operatorname{Cov}(L\mathbf{z})=LIL^\mathsf{T}=LL^\mathsf{T}=\Omega\). (4) A singular matrix has at least one zero-variance direction, so the draws lie in a lower-dimensional subspace; singularity is valid when the matrix remains positive semidefinite. (5) Verify that the factor reconstructs the intended matrix, and compare empirical simulated variances and correlations with the corresponding entries and correlations implied by \(\Omega\).

Clinical Biostats