Tutorials › Nonlinear Mixed-Effects Models (NLME) › Worked Decomposition of Subject, Occasion, and Residual Variance

Between-Subject, Between-Occasion and Residual Variability · Tutorial 140 of 797

Worked Decomposition of Subject, Occasion, and Residual Variance

Work through a replicated-period variance decomposition and learn what subject, occasion, and residual components mean on the model’s scale.

Intermediate 9 min read

What You'll Learn

  • Specify a log-concentration model with subject, occasion, and residual effects.
  • Calculate total modeled variance and the percentage contributed by each component.
  • Use covariance patterns across occasions and samples to distinguish components.
  • Interpret component sizes without treating them as causal or assay-only quantities.
  • Identify design and model conditions that make the decomposition unreliable.

Why separate three sources of variability?

Concentrations measured in a replicated-period study can differ because people differ, because a person's pharmacokinetics differ between occasions, and because individual observations depart from the model prediction. These sources have different implications: a subject effect persists across occasions, an occasion effect is shared by samples from the same occasion, and residual variation is specific to observations (unless the residual model adds correlation).

The key is to decompose variability on the scale of the fitted model. The worked model below uses log concentrations and random intercepts for subject and occasion. It is a deliberately simple decomposition at a matched design point; more elaborate NLME models may represent between-subject variation through random effects on clearance, volume, or other parameters, in which case the concentration-scale consequences can vary with time.

Definition: Let \(C_{soj}\) be the positive concentration for subject \(s\), occasion \(o\), and sample \(j\). At a specified design point, write $$ Y_{soj}=\ln\!\left(\frac{C_{soj}}{1\ \mathrm{mg/L}}\right) =\mu_{soj}+\eta_s+\kappa_{so}+\epsilon_{soj}. $$ Here \(\mu_{soj}=\ln(f_{soj}/(1\ \mathrm{mg/L}))\) is the log of the population model prediction \(f_{soj}\); \(\eta_s\) is the subject effect; \(\kappa_{so}\) is the occasion effect nested within subject; and \(\epsilon_{soj}\) is the residual. Assume \(\eta_s\sim N(0,\omega_{\mathrm{subject}}^2)\), \(\kappa_{so}\sim N(0,\omega_{\mathrm{occasion}}^2)\), and \(\epsilon_{soj}\sim N(0,\sigma^2)\). For this basic decomposition, the three sources are mutually independent, occasions have independent occasion effects, and residuals from distinct samples are independent with common variance.

The log is taken relative to \(1\ \mathrm{mg/L}\), so its argument is dimensionless. The component variances are therefore variances on the log-concentration scale. The subject effect is shared by all observations from a subject; the occasion effect is shared by observations from one subject on one occasion; the residual applies to one observation. Residual variation can include assay error and other unexplained within-occasion deviations, but it is not necessarily assay error alone.

What the decomposition says

At a fixed design point, subtracting the population prediction leaves the sum \(\eta_s+\kappa_{so}+\epsilon_{soj}\). Independence and zero means make the variance of this sum the sum of its component variances:

$$ \operatorname{Var}(Y_{soj}-\mu_{soj}) =\omega_{\mathrm{subject}}^2+\omega_{\mathrm{occasion}}^2+\sigma^2. $$

This total describes the marginal spread of a single log concentration around the population prediction under the stated model. It does not say that every subject or every occasion has all three effects of the same size. The effects are latent random deviations; the variances describe their modeled distributions across the population of subjects, occasions, or observations.

The covariance between observations also reflects which effects they share. For two distinct samples from the same subject and same occasion, the subject and occasion effects are shared, but the residuals are independent. For two observations from the same subject on different occasions, only the subject effect is shared. For observations from different subjects, none of these random effects is shared. The following derivation makes the first two patterns explicit.

Derivation: For distinct samples \(j\ne j'\) on the same occasion, subtracting their predictions gives \(R_j=\eta_s+\kappa_{so}+\epsilon_{soj}\) and \(R_{j'}=\eta_s+\kappa_{so}+\epsilon_{soj'}\). Independence and zero means imply $$ \operatorname{Cov}(R_j,R_{j'}) =\operatorname{Var}(\eta_s)+\operatorname{Var}(\kappa_{so}) =\omega_{\mathrm{subject}}^2+\omega_{\mathrm{occasion}}^2, $$ because each cross-covariance involving independent effects or distinct residuals is zero. On different occasions \(o\ne o'\), the occasion effects and residuals are independent across observations, while \(\eta_s\) remains shared, so $$ \operatorname{Cov}(R_{soj},R_{so'j'})=\omega_{\mathrm{subject}}^2. $$ Thus, under this model, the covariance difference between same-occasion and different-occasion observations from the same subject is \(\omega_{\mathrm{occasion}}^2\). This identity relies on the independence assumptions and matched design points.

Worked Example: Calculating the Component Shares

Suppose a hypothetical fitted model at a specified design point reports \(\omega_{\mathrm{subject}}^2=0.16\), \(\omega_{\mathrm{occasion}}^2=0.09\), and \(\sigma^2=0.04\), all on the log-concentration scale. Find the total variance, its standard deviation, and the percentage of that variance assigned to each component.

The total is $$ 0.16+0.09+0.04=0.29. $$ The marginal standard deviation is \(\sqrt{0.29}=0.5385\) log units. Each variance share is its component variance divided by the total variance: $$ \text{subject share}=\frac{0.16}{0.29}\times100\%=55.17\%,\qquad \text{occasion share}=\frac{0.09}{0.29}\times100\%=31.03\%, $$ $$ \text{residual share}=\frac{0.04}{0.29}\times100\%=13.79\%. $$ The rounded shares sum to approximately 100%. Under this model, the largest component of the single-observation log-scale variance is between-subject variability, followed by between-occasion variability and residual variability. These percentages describe a variance partition on the modeled scale; they are not percentages of concentration values or percentages of subjects affected.

Worked Example: Reading Covariances Across Replicates

In another hypothetical analysis, residuals at matched design points have estimated covariance \(0.25\) between distinct samples from the same occasion, and covariance \(0.16\) between samples from different occasions of the same subject. Assume the random-intercept model and independence conditions above. What occasion variance does the covariance pattern imply?

Different-occasion observations share only the subject effect, so the subject variance is \(0.16\). Same-occasion observations share both the subject and occasion effects, so $$ \omega_{\mathrm{subject}}^2+\omega_{\mathrm{occasion}}^2=0.25. $$ Subtract the different-occasion covariance: $$ \omega_{\mathrm{occasion}}^2=0.25-0.16=0.09. $$ The occasion variance is therefore \(0.09\) log units squared, with occasion standard deviation \(\sqrt{0.09}=0.300\) log units. This is an interpretation of the model’s covariance structure, not a claim that simply subtracting two noisy empirical covariances is always an appropriate estimation procedure. In practice, the reported components come from fitting the full model, and their uncertainty matters.

Worked from effects to concentrations

A component is additive in the log model, not in the concentration itself. Exponentiating gives $$ C_{soj}=f_{soj}\exp(\eta_s+\kappa_{so}+\epsilon_{soj}). $$ Thus a positive log-scale deviation multiplies the population prediction by a factor greater than one, while a negative deviation multiplies it by a factor below one. The components should not be added as concentration differences.

Worked Example: Following Three Effects Through the Model

Consider hypothetical observations at a design point where \(f=10.0\ \mathrm{mg/L}\). For one subject and occasion, suppose the illustrative effects are \(\eta_s=0.20\), \(\kappa_{so}=0.10\), and \(\epsilon_{soj}=-0.05\). Find the modeled concentration for this observation.

The total log deviation is \(0.20+0.10-0.05=0.25\). Therefore, $$ C=10.0\exp(0.25)\ \mathrm{mg/L} =10.0(1.284)\ \mathrm{mg/L} =12.84\ \mathrm{mg/L}. $$ The subject and occasion contributions are shared with other observations from that subject and occasion, respectively; the residual contribution is specific to this observation. These chosen effects illustrate the arithmetic and are not estimates for a real study.

The log-scale variance fractions from the first example should not be described as fractions of the variance in raw concentrations. Under the special assumptions that the log deviation is normal and the prediction is fixed, the raw concentration is lognormal. If the total log variance is \(v\), then its mean is \(f\exp(v/2)\) and its variance is \(f^2\exp(v)\{\exp(v)-1\}\). The transformation is nonlinear, so raw-scale variance contributions do not in general equal the log-scale component variances or their percentages. Report the scale and the quantity being decomposed whenever presenting a variance breakdown.

Assumptions, diagnostics, and alternatives

The decomposition is useful only insofar as its structure is plausible and the study has information to distinguish the components. Replicated occasions help distinguish a persistent subject effect from occasion-to-occasion variation. Multiple samples within occasions help distinguish occasion effects from observation-level residual variation. If every subject has only one occasion, the subject and occasion contributions are difficult or impossible to separate from these data without additional structure or information.

Check the interpretation against the study design and model. In particular, ask whether the occasions truly represent repeated periods within subjects, whether the same occasion effect should act on all samples within a period, and whether residuals plausibly have constant variance and no remaining serial correlation on the chosen scale. Look for residual patterns against predictions, time, and occasion; compare observed within-subject covariance patterns with those implied by the fitted model; and check whether estimates are near zero, imprecise, or sensitive to model specification. A variance estimate near zero can indicate little evidence for that component, but can also reflect limited replication or weak separation from another component.

This random-intercept decomposition is not the only way to represent variability. A residual error model can allow residual variance to depend on the predicted concentration or use additive and proportional terms; the earlier material on residual error models treats those choices. Such residual specifications do not automatically replace a shared occasion effect: one is observation-level variance structure, the other induces dependence among samples from the same occasion. A model with occasion-specific random effects on PK parameters can also produce occasion variability, but its effect on concentrations may change with time and concentration. In that setting, a single constant occasion variance at every design point may not be adequate.

A common mistake is to add three reported standard deviations and call the result total variability. Under independent additive effects, it is the variances that add: the total standard deviation is the square root of their sum. Another mistake is to call the residual component “assay error.” It is the unexplained observation-level variation under the model and may combine assay error with other sources. Finally, a component share is a model-based description, not a causal attribution to a biological mechanism.

Key takeaway: In the stated replicated-period model, subject variance is shared across a subject’s occasions, occasion variance is additionally shared within an occasion, and residual variance applies to individual observations. Their sum gives the marginal log-scale variance at a matched design point, provided the model’s independence and variance assumptions are reasonable.

Check Your Understanding

Answer each question using the model and assumptions given above. Solutions follow the questions.

  1. If the subject, occasion, and residual variances are \(0.10\), \(0.05\), and \(0.05\), what is the total log-scale variance and what percentage is assigned to the occasion component?
  2. Which random effects are shared by two distinct samples from the same subject but different occasions?
  3. A same-occasion covariance is \(0.30\), while a different-occasion covariance for the same subject is \(0.22\). Under the stated model, what occasion variance is implied?
  4. Why is a residual variance component not automatically an estimate of assay error alone?

Solutions: (1) The total is \(0.10+0.05+0.05=0.20\); the occasion share is \(0.05/0.20\times100\%=25\%\). (2) Only the subject effect is shared; the occasion effects differ and distinct observations have independent residuals under the model. (3) The implied occasion variance is \(0.30-0.22=0.08\) log units squared. (4) Residual variation represents observation-level deviations left unexplained by the model, which can include assay error and other within-occasion sources.