Tutorials › Pharmacometric Workflows and Reproducible Modeling › Conditional Versus Marginal Random-Effects Sampling

Simulation Pipelines · Tutorial 255 of 399

Conditional Versus Marginal Random-Effects Sampling

Learn when to sample random effects from the population distribution and when to condition on subject data, and how that choice changes predictions.

Advanced 11 min read

What You'll Learn

  • Distinguish population-level random-effects draws from subject-conditional draws
  • Identify what subject information does—and does not—condition a random effect
  • Derive a conditional random-effects distribution in a normal example
  • Calculate how conditional and marginal draws change individual predictions
  • Diagnose inappropriate reuse of subject-conditional draws for population targets
  • Choose a sampling approach that matches the prediction target

Why the Sampling Target Matters

A random effect represents an individual’s deviation from the typical model parameters. But a simulation must specify whether it represents a new individual from a target population or a particular individual about whom data are already available. Those are different prediction targets, and they generally require different random-effects draws.

For a new virtual subject, the random effect is drawn from the population distribution. For a known subject, observed subject-specific data can update what is plausible for that person; predictions should then use the random effect’s distribution conditional on those data. Using the population distribution for a known subject ignores information. Using a subject-conditional distribution to represent new subjects instead carries information from the observed subjects into the simulated population.

Definition: A marginal (population-level) random-effects draw is drawn from the model’s population distribution for a random effect, without conditioning on that subject’s observed outcomes. A conditional (subject-specific) random-effects draw is drawn from the distribution of that effect conditional on the subject’s available data and the specified model. “Marginal” refers here to averaging over the population random-effects distribution; it does not mean that the effect is known for an individual.

Model and Conditioning Information

Let \(\eta_i\) denote the vector of random effects for subject \(i\). In a standard population model, conditional on the model parameters, the population distribution is

$$ \eta_i \sim N(0,\Omega), $$

where \(\Omega\) is the random-effects covariance matrix. Individual parameters are functions of the typical parameters, subject covariates, and random effects; for example, a positive clearance parameter may be written as \(CL_i=CL_{\mathrm{typ}}\exp(\eta_{CL,i})\). A marginal simulation for a new subject draws \(\eta_i\) from \(N(0,\Omega)\), then applies the individual-parameter and prediction equations.

For a known subject, let \(y_i\) denote the subject-specific observations used for conditioning, and let \(x_i\) denote known covariates. With model parameters held fixed, the conditional distribution is

$$ p(\eta_i\mid y_i,x_i) \propto p(y_i\mid \eta_i,x_i)\,p(\eta_i\mid x_i). $$

This is a posterior distribution for the subject’s random effect under the specified model. If random effects are independent of covariates in the model, then \(p(\eta_i\mid x_i)=p(\eta_i)\). In that case, knowing a subject’s covariates alone does not update the random effect; subject-specific outcome information is needed. If the model specifies dependence between covariates and random effects, that dependence must instead be represented in the conditional distribution.

The conditional distribution is usually not the same as the population distribution. A subject with data that suggest unusually low clearance, for example, will generally have a conditional distribution shifted toward lower clearance-related random effects. It will also retain uncertainty: a conditional draw is not the same as setting the random effect equal to a single estimated value.

Worked Example: Population and Subject-Conditional Clearance

Worked Example: Population and Subject-Conditional Clearance

Suppose a hypothetical model has \(CL_{\mathrm{typ}}=10\) L/h and \(\eta_{CL}\sim N(0,0.09)\). Thus the random-effect standard deviation is \(0.3\), and \(CL=10\exp(\eta_{CL})\) L/h. For a particular subject, suppose the model’s conditional distribution based on that subject’s observed data is \(N(-0.20,0.04)\). Compare the two draws.

Population draw. A central 95% range for \(\eta_{CL}\), using the normal approximation, is \(0\pm1.96(0.3)\), or \([-0.588,0.588]\). Transforming to clearance gives

$$ [10\exp(-0.588),\,10\exp(0.588)] \approx [5.55,18.0]\ \text{L/h}. $$

The population median clearance is \(10\exp(0)=10.0\) L/h. These values describe variation across new subjects under the model, not uncertainty about this particular subject.

Conditional draw. The conditional standard deviation is \(\sqrt{0.04}=0.20\), so a central 95% range for the subject’s random effect is \(-0.20\pm1.96(0.20)\), or \([-0.592,0.192]\). On the clearance scale this becomes

$$ [10\exp(-0.592),\,10\exp(0.192)] \approx [5.53,12.1]\ \text{L/h}. $$

The conditional median is \(10\exp(-0.20)\approx8.19\) L/h. It is below the population median because the subject’s data shifted the conditional distribution downward. The two intervals are not interchangeable: one represents population heterogeneity, while the other represents uncertainty about a known subject under the model.

Deriving a Conditional Distribution

A simple normal model shows explicitly how subject data update a random effect. Suppose a hypothetical subject-specific summary \(z_i\) measures the random effect with independent normal error:

$$ \eta_i\sim N(0,\tau^2),\qquad z_i\mid\eta_i\sim N(\eta_i,\sigma^2). $$

Here \(\tau^2\) is the population variance and \(\sigma^2\) is the variance of the measurement error in this summary. Completing the square in the product of the normal prior density and the normal likelihood gives a normal conditional distribution with variance \(V\) and mean \(m_i\):

$$ V=\left(\frac{1}{\tau^2}+\frac{1}{\sigma^2}\right)^{-1}, \qquad m_i=V\frac{z_i}{\sigma^2}, \qquad \eta_i\mid z_i\sim N(m_i,V). $$

The precision \(1/V\) is the sum of the prior precision and the data precision. Thus the conditional distribution combines the population information with the subject’s information rather than replacing one with the other. This derivation depends on the stated normal model, known variances, and independent measurement error; it is not a general formula for every nonlinear mixed-effects model.

Worked Example: Updating a Random Effect From a Subject Summary

Assume the hypothetical normal model above, with \(\tau^2=0.09\), \(\sigma^2=0.04\), and an observed summary \(z_i=-0.15\). The subject’s conditional distribution is

Conditional variance.

$$ V=\left(\frac{1}{0.09}+\frac{1}{0.04}\right)^{-1} =(11.111+25)^{-1} \approx0.02769. $$

Conditional mean.

$$ m_i=0.02769\left(\frac{-0.15}{0.04}\right) =0.02769(-3.75) \approx-0.1038. $$

Therefore, \(\eta_i\mid z_i\sim N(-0.1038,0.02769)\), rather than \(N(0,0.09)\). The negative summary shifts the conditional mean below zero, while the conditional variance is smaller than the population variance because the summary supplies information. Neither change implies that \(\eta_i\) is known exactly.

If clearance is \(10\exp(\eta_i)\) L/h, its conditional median is \(10\exp(-0.1038)\approx9.014\) L/h. For a lognormal variable, the mean includes the variance term:

$$ E(CL_i\mid z_i) =10\exp\left(m_i+\frac{V}{2}\right) =10\exp(-0.1038+0.01385) \approx9.139\ \text{L/h}. $$

For comparison, the population mean clearance is \(10\exp(0+0.09/2)\approx10.46\) L/h. The conditional and population means answer different questions.

Prediction Depends on the Target Quantity

The difference between conditional and marginal sampling can become more pronounced after transforming random effects into predictions. In general, a population prediction averages over the population distribution of random effects, whereas a prediction for a known subject averages over that subject’s conditional distribution. For a prediction function \(g\), these targets are

$$ E\{g(\eta_i)\} \quad\text{and}\quad E\{g(\eta_i)\mid y_i,x_i\}, $$

respectively. They need not be equal. In particular, applying a nonlinear function to the mean random effect generally does not give the mean prediction. This is why simulation should draw random effects from the distribution appropriate to the target, transform each draw through the model, and then summarize the resulting predictions.

Worked Example: AUC Under Population and Conditional Sampling

Continue with the hypothetical model from the previous example: \(CL_i=10\exp(\eta_i)\) L/h, and let a single dose be 100 mg. Under a linear clearance relationship, the corresponding AUC is \(100/CL_i=10\exp(-\eta_i)\) mg·h/L. Compare its mean for a new subject with its conditional mean for the subject with \(z_i=-0.15\).

New subject. With \(\eta_i\sim N(0,0.09)\), the lognormal mean formula gives

$$ E(AUC_i)=10\exp\left(0+\frac{0.09}{2}\right) =10\exp(0.045) \approx10.46\ \text{mg·h/L}. $$

Known subject. With \(\eta_i\mid z_i\sim N(-0.1038,0.02769)\), the random variable \(-\eta_i\) has mean \(0.1038\) and variance \(0.02769\). Hence

$$ E(AUC_i\mid z_i) =10\exp\left(0.1038+\frac{0.02769}{2}\right) =10\exp(0.1177) \approx11.25\ \text{mg·h/L}. $$

The conditional mean AUC is higher because the subject’s data shifted the clearance random effect downward. These are model-based predictions under the stated assumptions, not claims that the simulated subject’s true AUC is known. The calculation concerns the model prediction; it does not add residual observation error.

Choosing a Sampling Approach and Checking It

First state the prediction target. For a new virtual population, draw random effects from the model’s population distribution, together with covariates from the target population as appropriate. For a particular observed subject, draw from the conditional distribution given that subject’s data. When model-parameter uncertainty is also being propagated, keep it conceptually separate: a conditional random-effects draw given fixed parameters does not by itself represent uncertainty in those parameters.

A plug-in individual estimate, such as a single empirical Bayes estimate, is a computationally simpler alternative to conditional draws. It can be useful for a point prediction, but it suppresses conditional uncertainty. Conditional draws retain that uncertainty under the model. For new-subject population predictions, marginal draws represent between-subject variation; assigning every new subject the same plug-in estimate does not.

Several checks help reveal a mismatch between the target and the simulation:

  • Check what was conditioned on. Record whether the conditional distribution used subject outcomes, covariates, or both. Covariates alone do not update random effects under a model that makes them independent.
  • Check the simulated distribution. For new subjects, draws should reproduce the specified population distribution before transformations. For known subjects, check that draws reflect the fitted conditional distribution, including its uncertainty.
  • Check the prediction target. A population prediction should not be built by repeatedly drawing from the conditional distributions of a selected set of observed subjects unless that selected group is explicitly the target.
  • Check transformations and units. Compare predictions after applying the individual-parameter equations. A correct random-effects distribution can still produce an incorrect prediction if the transformation or parameter units are wrong.

Conditional predictions are model-dependent: misspecified likelihoods, influential observations, or weak information for a subject can make the conditional distribution unreliable or overly dependent on modeling assumptions. Population predictions also depend on the specified random-effects distribution and target population. Neither sampling choice repairs a poorly specified model, and neither should be interpreted as including uncertainty sources that were not actually simulated.

Common pitfall: “I have covariates for each simulated subject, so I should draw each random effect conditionally.” This is not generally correct. If the model specifies independence between covariates and random effects, covariates determine the typical parameter values but do not condition the random effects. For new subjects, draw from the population random-effects distribution; condition on subject-specific outcome data only when the target is a known subject and those data are intended to inform the prediction.
Key takeaway: Match the random-effects distribution to the prediction target. Use population draws for new subjects and subject-conditional draws for known subjects with relevant data. Then propagate each draw through the model before summarizing predictions.

Check Your Understanding

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

  1. A model assumes \(\eta_i\) is independent of age. For a new virtual subject whose age is known but who has no outcome data, which random-effects distribution should be used?
  2. In the normal update example, what is the conditional variance if the observed summary is changed but the prior and measurement variances stay fixed? Explain.
  3. For a known subject, why can a conditional random-effects draw be preferable to using one individual estimate?
  4. A simulation uses conditional draws from a small, selected set of observed subjects to represent an entire target population. State the main concern.

Solutions. (1) Use the population distribution \(N(0,\Omega)\): under the stated independence assumption, knowing age alone does not update \(\eta_i\). (2) It remains \(V=(1/0.09+1/0.04)^{-1}\approx0.02769\), because the formula for the variance depends on the two variances, not on the observed value \(z_i\). (3) Conditional draws retain uncertainty about the subject’s random effect; a single estimate treats it as fixed and omits that uncertainty. (4) The selected subjects’ data have shifted and narrowed their conditional distributions, so those draws may not represent the population distribution or the stated target population.

Clinical Biostats