Tutorials › Nonlinear Mixed-Effects Models (NLME) › Deriving Residual Variance Functions From Observation Models

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

Deriving Residual Variance Functions From Observation Models

Learn to translate an observation-scale likelihood into its conditional variance function and distinguish exact variance results from delta-method approximations.

Intermediate 10 min read

What You'll Learn

  • Define residual variance conditional on the model prediction and random effects.
  • Derive the constant variance implied by an additive-error likelihood.
  • Derive the prediction-squared variance implied by proportional error.
  • Use a local inverse-transformation expansion to obtain a transformed-error variance.
  • Distinguish the exact lognormal variance from its first-order approximation.
  • Recognize when a variance function does not describe marginal variability across subjects.

From an Observation Model to a Variance Function

In an NLME model, the structural model gives a prediction for an observation, while the observation model describes how measured values vary around that prediction. The observation model may be specified by a likelihood or by an equation involving a residual error. Either way, it implies a variance at the scale on which the data are recorded. Deriving that variance makes clear what assumptions about precision are built into the model.

Write \(Y_{ij}\) for the observation on subject \(i\) at observation occasion \(j\), and \(F_{ij}\) for its model prediction. The prediction may depend on time, dose, subject effects, and occasion effects. The residual variance considered here is conditional on the prediction and those effects. It describes observation-level variability after holding the model state fixed; it is not the total variability among observations from a population.

Definition: The conditional residual variance function is \(V(F_{ij})=\operatorname{Var}(Y_{ij}\mid F_{ij})\), where the conditioning holds the model prediction and its relevant covariates or latent effects fixed. The function \(V\) states how the variance of recorded observations changes, or does not change, with the prediction.

A variance function is a consequence of the observation model, not an independent description that can be chosen without regard to the likelihood. For example, if an observation is modeled as its prediction plus a mean-zero error with constant variance, the implied variance is constant. If the error is scaled by the prediction, the implied variance depends on the squared prediction. The same symbol for a residual term should not obscure these different assumptions.

Additive and Proportional Error

Under an additive observation model, write \(Y_{ij}=F_{ij}+\epsilon_{ij}\), with \(E(\epsilon_{ij}\mid F_{ij})=0\) and \(\operatorname{Var}(\epsilon_{ij}\mid F_{ij})=\sigma_a^2\). The recorded observation has conditional mean \(F_{ij}\). Adding a fixed prediction does not change variance, so its conditional variance is \(\sigma_a^2\), regardless of the size of \(F_{ij}\).

$$ \operatorname{Var}(Y_{ij}\mid F_{ij}) =\operatorname{Var}(F_{ij}+\epsilon_{ij}\mid F_{ij}) =\sigma_a^2. $$

This is constant absolute precision: the typical residual scale is the same in the units of \(Y\) across predictions. It is appropriate as a description when measurement scatter is approximately constant in those units. The derivation itself does not establish that the assumption is suitable for a particular data set.

Worked Example: Variance Under Additive Error

Suppose a hypothetical assay observation has prediction \(F_{ij}=8.0\) mg/L, and an additive-error model specifies a residual standard deviation of \(\sigma_a=0.60\) mg/L. The residual is conditionally mean zero and has constant variance.

The variance function is \(V(F_{ij})=\sigma_a^2\). Substitution gives \(\operatorname{Var}(Y_{ij}\mid F_{ij})=(0.60\ \text{mg/L})^2=0.360\ (\text{mg/L})^2\). The standard deviation is \(0.60\) mg/L whether the prediction is 8.0 mg/L or another value. This is a hypothetical calculation illustrating the model, not a claim about a real assay.

Under a proportional-error model, write \(Y_{ij}=F_{ij}(1+\epsilon_{ij})\), where the relative error has conditional mean zero and variance \(\sigma_p^2\). For a fixed prediction, multiplying a random variable by \(F_{ij}\) multiplies its variance by \(F_{ij}^2\). Therefore,

$$ E(Y_{ij}\mid F_{ij})=F_{ij},\qquad \operatorname{Var}(Y_{ij}\mid F_{ij})=F_{ij}^2\sigma_p^2. $$

Here \(\sigma_p\) is dimensionless, and the conditional standard deviation is \(|F_{ij}|\sigma_p\). For positive predictions, the conditional coefficient of variation—the standard deviation divided by the conditional mean—is \(\sigma_p\). Thus proportional error represents approximately constant relative precision rather than constant absolute precision. The normal-error version of this model can assign probability to negative observations; that may be negligible for small relative error but is a limitation when nonnegative measurements are required.

Worked Example: Variance Under Proportional Error

Consider a hypothetical prediction of \(F_{ij}=4.0\) mg/L and a proportional residual standard deviation \(\sigma_p=0.15\). Assume the relative error has mean zero and variance \(0.15^2\), conditional on the prediction.

The implied variance is \(F_{ij}^2\sigma_p^2\): \( (4.0\ \text{mg/L})^2(0.15)^2 =16.0\ (\text{mg/L})^2\times0.0225 =0.360\ (\text{mg/L})^2\). The conditional standard deviation is \(\sqrt{0.360}=0.600\) mg/L. Its ratio to the prediction is \(0.600/4.0=0.15\), or 15%. If the prediction doubled to 8.0 mg/L while \(\sigma_p\) stayed fixed, the variance would be \(64(0.0225)=1.44\ (\text{mg/L})^2\), four times as large, and the standard deviation would double.

Transformed-Scale Error and the Delta Method

A transformed observation model places the residual error on a transformed scale. Let \(g\) be a transformation and write \(g(Y_{ij})=g(F_{ij})+\epsilon_{ij}\), where \(E(\epsilon_{ij}\mid F_{ij})=0\) and \(\operatorname{Var}(\epsilon_{ij}\mid F_{ij})=\tau^2\). To translate this model to the observation scale, let \(h=g^{-1}\), so that \(Y_{ij}=h(g(F_{ij})+\epsilon_{ij})\).

For a local first-order approximation, the inverse transformation must be differentiable at \(g(F_{ij})\), with derivative \(h'(g(F_{ij}))=1/g'(F_{ij})\). A standard sufficient condition is that \(g\) be continuously differentiable near \(F_{ij}\) and \(g'(F_{ij})\ne0\). Taylor expansion around the prediction on the transformed scale gives the justification:

$$ Y_{ij} =h(g(F_{ij})+\epsilon_{ij}) \approx h(g(F_{ij}))+h'(g(F_{ij}))\epsilon_{ij} =F_{ij}+h'(g(F_{ij}))\epsilon_{ij}. $$

Taking the variance of the first-order expression, conditional on \(F_{ij}\), yields the delta-method approximation

$$ \operatorname{Var}(Y_{ij}\mid F_{ij}) \approx [h'(g(F_{ij}))]^2\tau^2 =\frac{\tau^2}{[g'(F_{ij})]^2}. $$

The squared derivative is essential: variance scales by the square of a multiplicative change. This result is approximate because the Taylor expansion omits curvature and higher-order terms. It is most useful when residual variation on the transformed scale is small enough that the local linear approximation is adequate. It does not, by itself, imply that the observation-scale conditional mean is exactly \(F_{ij}\).

Worked Example: Log-Scale Error and Exact Variance

For a positive hypothetical concentration, suppose the observation model is \(\log(Y_{ij})=\log(F_{ij})+\epsilon_{ij}\), with \(\epsilon_{ij}\sim N(0,\tau^2)\), independent of the fixed prediction, and \(\tau^2=0.04\). Let \(F_{ij}=5.0\) mg/L. Then \(Y_{ij}=F_{ij}\exp(\epsilon_{ij})\); the prediction \(F_{ij}\) is the conditional median, not the conditional arithmetic mean.

For a normal random variable \(\epsilon_{ij}\sim N(0,\tau^2)\), its exponential has \(E[\exp(\epsilon_{ij})]=\exp(\tau^2/2)\) and \(\operatorname{Var}[\exp(\epsilon_{ij})]=\exp(\tau^2)(\exp(\tau^2)-1)\). Multiplying by the fixed \(F_{ij}\) gives the exact observation-scale variance \(\operatorname{Var}(Y_{ij}\mid F_{ij})=F_{ij}^2\exp(\tau^2)(\exp(\tau^2)-1)\).

Substitution gives \(25\ (\text{mg/L})^2\times\exp(0.04)\times[\exp(0.04)-1]\). With \(\exp(0.04)\approx1.04081\), this is \(25(1.04081)(0.04081)\approx1.062\ (\text{mg/L})^2\); the conditional standard deviation is approximately \(1.030\) mg/L. The first-order delta-method result uses \(g(y)=\log(y)\), so \(g'(F)=1/F\), giving \(F_{ij}^2\tau^2=25(0.04)=1.000\ (\text{mg/L})^2\). The two answers differ because the delta method is an approximation, whereas the exponential calculation is exact under the stated normal log-error model.

The same moment calculation gives the conditional mean \(5.0\exp(0.02)\approx5.101\) mg/L, rather than 5.0 mg/L. Thus a model centered at \(\log(F_{ij})\) does not generally center observations at \(F_{ij}\) on the original scale.

What the Variance Function Does—and Does Not—Describe

The residual variance function is conditional. If predictions differ because subjects have different random effects, the population-level variance also reflects variation in those effects. In general, for a random prediction \(F_{ij}\), the law of total variance states

$$ \operatorname{Var}(Y_{ij}) =E\{\operatorname{Var}(Y_{ij}\mid F_{ij})\} +\operatorname{Var}\{E(Y_{ij}\mid F_{ij})\}. $$

The first term averages conditional residual variance over predictions; the second captures variation in conditional means. Consequently, a constant additive residual variance does not mean that all observations in the population have the same total variance, and a prediction-dependent residual variance does not by itself describe between-subject or between-occasion variability.

A useful check is to compare the assumed variance pattern with residuals at different prediction levels, while remembering that structural-model errors can also appear as residual patterns. Under a proposed variance function \(V(F_{ij})\), standardized residuals are \(r_{ij}=(Y_{ij}-E[Y_{ij}\mid F_{ij}])/\sqrt{V(F_{ij})}\), when the conditional mean and variance are defined by the model. If their spread changes systematically with prediction, the variance specification or another part of the model may be inadequate. Such a pattern is a warning, not proof that a particular alternative is correct.

Observation modelConditional variance on observation scalePrecision pattern
Additive, mean-zero error with variance \(\sigma_a^2\)\(\sigma_a^2\)Constant absolute residual scale
Proportional error with variance \(\sigma_p^2\) on relative scale\(F_{ij}^2\sigma_p^2\)Constant relative residual scale for positive predictions
Transformed error with variance \(\tau^2\)Approximately \(\tau^2/[g'(F_{ij})]^2\) by first-order delta methodDepends on the transformation and prediction

Assumptions, Alternatives, and Common Pitfalls

These derivations condition on the prediction and require the stated conditional residual moments. They do not require that residuals from different observations be independent merely to calculate each observation's variance. Independence is an additional likelihood assumption often used for the joint observation model; if residuals are correlated, the marginal variance at each observation can still be as derived, but the joint covariance also needs specification.

The main alternatives encode different relationships between prediction and precision. Additive error keeps absolute variance fixed; proportional error makes variance grow quadratically with prediction; transformed error induces a variance determined by the local slope of the transformation. Choosing among them should reflect measurement behavior and the data, not just which formula is easiest to fit. A transformation can also change the conditional mean after returning to the observation scale, as the log example demonstrates.

  • Pitfall: treating transformed-scale variance as observation-scale variance. If \(\operatorname{Var}(\epsilon_{ij}\mid F_{ij})=\tau^2\) on the transformed scale, it does not follow that \(\operatorname{Var}(Y_{ij}\mid F_{ij})=\tau^2\). The transformation's derivative scales the variance locally, and the exact result may require more than a first-order approximation.
  • Pitfall: confusing variance with standard deviation. Proportional error gives variance \(F_{ij}^2\sigma_p^2\), but standard deviation \(|F_{ij}|\sigma_p\). The variance has squared observation units; the standard deviation has the original units.
  • Pitfall: interpreting conditional residual variance as total variability. The function \(V(F_{ij})\) holds subject and occasion effects fixed. Variation in predictions contributes additional marginal variability.

The derivations identify what each observation model entails; they do not establish which model fits a given assay or data set. A local approximation can be poor when the transformed-scale error is large or the inverse transformation is strongly curved over the relevant range. In those situations, use the exact variance when available or evaluate the observation model directly rather than treating the delta-method expression as exact.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. An additive-error model has \(\sigma_a=0.4\) mg/L. What is its conditional residual variance, and what are its units?
  2. Under proportional error, \(F_{ij}=6\) mg/L and \(\sigma_p=0.10\). Find the conditional variance and standard deviation.
  3. For transformed error \(g(Y)=g(F)+\epsilon\), state the first-order variance approximation and the regularity condition needed for the inverse transformation.
  4. Why is the prediction \(F\) in a normal log-error model generally not the conditional arithmetic mean of \(Y\)?
  5. Does a conditional residual variance function alone equal the marginal variance when predictions vary among subjects? Explain briefly.

Solutions. (1) \(0.4^2=0.160\ (\text{mg/L})^2\). (2) \(6^2(0.10)^2=0.360\ (\text{mg/L})^2\), with standard deviation \(0.600\) mg/L. (3) \(\operatorname{Var}(Y\mid F)\approx\tau^2/[g'(F)]^2\); the inverse must be differentiable at \(g(F)\), for example because \(g\) is continuously differentiable nearby and \(g'(F)\ne0\). (4) If \(\log(Y)=\log(F)+\epsilon\) and \(\epsilon\sim N(0,\tau^2)\), then \(E(Y\mid F)=F\exp(\tau^2/2)\), which exceeds \(F\) when \(\tau^2>0\). (5) No. Marginal variance also includes variation in the conditional mean across predictions, as expressed by the law of total variance.