Tutorials › Nonlinear Mixed-Effects Models (NLME) › Residual Error Patterns Across Predicted Concentrations

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

Residual Error Patterns Across Predicted Concentrations

Use residual-versus-prediction plots and binned summaries to identify how residual spread changes across predicted concentrations and to recognize when a pattern needs further investigation.

Intermediate 11 min read

What You'll Learn

  • Define raw residuals relative to individual predicted concentrations.
  • Relate constant, proportional, and combined error models to their expected residual spreads.
  • Calculate and interpret binned residual means and sample standard deviations.
  • Use residual-versus-prediction plots to look for changing spread and systematic bias.
  • Recognize how finite bin sizes, dependence, and prediction variation can complicate interpretation.
  • Distinguish descriptive diagnostics from evidence that establishes a residual model.

Why Plot Residuals Against Predicted Concentration?

A residual-versus-prediction plot asks whether the discrepancies between observed and predicted concentrations change systematically across the concentration range. This matters because residual error models make different predictions about the spread of those discrepancies. A plot can reveal a pattern that is difficult to see in a single overall residual summary, but it is a diagnostic, not a model-selection rule: an apparent pattern can also reflect sampling variation, dependence, or problems with the predictions themselves.

For observation \(j\) from subject \(i\), let \(C_{ij}\) be the observed concentration and let \(\hat C_{ij}\) be the model-predicted concentration used for diagnosis. The prediction should be identified clearly; in a typical diagnostic it is an individual prediction conditional on the fitted subject effects. The raw residual is the observation minus that prediction. The residual is measured in the same concentration units as \(C_{ij}\).

Definition: The raw residual for observation \(j\) from subject \(i\) is \(e_{ij}=C_{ij}-\hat C_{ij}\). A positive residual means the observation is above its prediction; a negative residual means it is below. A residual-versus-prediction plot places \(\hat C_{ij}\) on the horizontal axis and \(e_{ij}\) on the vertical axis.

To interpret the vertical spread, begin with a residual model whose conditional mean is zero and whose variance is specified as a function of predicted concentration. The following descriptions use \(\hat C_{ij}\) as the concentration scale at which the error variance is evaluated. They concern the residual distribution conditional on the model prediction and relevant subject effects, under the assumed residual model. They do not say that every observed residual must be near zero or that a finite plot will display the theoretical pattern perfectly.

Residual variance patterns: A constant-error model has \(\operatorname{Var}(e_{ij}\mid\hat C_{ij})=\sigma_a^2\). A proportional-error model has \(\operatorname{Var}(e_{ij}\mid\hat C_{ij})=\sigma_p^2\hat C_{ij}^{\,2}\). A combined additive and proportional model has \(\operatorname{Var}(e_{ij}\mid\hat C_{ij})=\sigma_a^2+\sigma_p^2\hat C_{ij}^{\,2}\). Here \(\sigma_a\) is in concentration units and \(\sigma_p\) is dimensionless when the prediction and observation use the same concentration units.

The corresponding conditional residual standard deviations are \(\sigma_a\), \(\sigma_p\hat C_{ij}\), and \(\sqrt{\sigma_a^2+\sigma_p^2\hat C_{ij}^{\,2}}\), respectively, for nonnegative predicted concentrations. Thus constant error suggests roughly even vertical spread; proportional error suggests spread increasing roughly in proportion to prediction; and combined error includes a nonzero low-concentration component plus an increasing component. These are patterns to assess, not shapes that each individual point must follow.

Summarizing Spread Within Prediction Bins

A scatterplot can be dense, so it is often useful to divide predictions into ranges, or bins, and summarize the residuals in each range. Bins might be defined by prediction intervals or chosen to have similar numbers of observations. For bin \(b\) containing \(n_b\) residuals, calculate its mean and sample standard deviation:

$$ \bar e_b=\frac{1}{n_b}\sum_{k=1}^{n_b} e_{bk}, \qquad s_b=\sqrt{\frac{1}{n_b-1}\sum_{k=1}^{n_b}(e_{bk}-\bar e_b)^2}. $$

The bin mean \(\bar e_b\) describes the average signed discrepancy in that range. A mean consistently above or below zero can indicate systematic overprediction or underprediction in that range. The sample standard deviation \(s_b\) describes the within-bin spread around that bin's own mean. It is a descriptive estimate, not an exact value of the model's residual standard deviation. It varies with finite sample size and can be unrepresentative when residuals are dependent or when predictions and residual properties vary substantially within a bin.

A constant shift in all residuals in a bin changes \(\bar e_b\), but does not change \(s_b\): subtracting the bin mean removes that shift. Shifts that vary among observations within the bin can contribute to the spread. For example, if different prediction levels within a wide bin have different conditional residual means, their deviations from the bin mean add a between-level component to the measured spread. This is one reason to avoid overly broad bins.

For independent residuals with conditional means \(\mu_k\) and variances \(v_k\), the expected sample variance within a bin is

$$ E(s_b^2)=\frac{1}{n_b}\sum_{k=1}^{n_b}v_k +\frac{1}{n_b-1}\sum_{k=1}^{n_b}(\mu_k-\bar\mu)^2, \qquad \bar\mu=\frac{1}{n_b}\sum_{k=1}^{n_b}\mu_k. $$

This follows by writing each residual as its mean plus a zero-mean deviation. The expected sum of squared deviations from the sample mean separates into the sum of the individual variances, adjusted for estimating the mean, and the squared differences among the conditional means. If every conditional mean is shifted by the same constant, then \(\mu_k-\bar\mu=0\) for all \(k\), so that shift does not inflate the expected sample variance. If the means differ within the bin, the second term is positive. Dependence changes this calculation, so the displayed expression relies on independence.

Worked Example: Approximately Constant Spread

Suppose a hypothetical diagnostic has three raw residuals in a low-prediction bin (predictions from 1 to 3 mg/L): \(-2, 0, 2\) mg/L. A second bin (predictions from 7 to 9 mg/L) contains \(-2.1, 0, 2.1\) mg/L. Calculate each mean and sample standard deviation.

For the low bin, \(\bar e_1=(-2+0+2)/3=0\) mg/L. Its sample variance is \([(-2-0)^2+(0-0)^2+(2-0)^2]/(3-1)=8/2=4\) \((\mathrm{mg/L})^2\), so \(s_1=\sqrt{4}=2.00\) mg/L.

For the high bin, \(\bar e_2=(-2.1+0+2.1)/3=0\) mg/L. Its sample variance is \([(-2.1)^2+0^2+(2.1)^2]/2=8.82/2=4.41\) \((\mathrm{mg/L})^2\), so \(s_2=\sqrt{4.41}=2.10\) mg/L.

These two small bins have similar spreads despite quite different prediction ranges. That is compatible with a constant-error pattern, but it does not establish one: three residuals per bin give imprecise summaries, and the full plot and model assumptions still matter.

Reading the Three Main Patterns

Error patternExpected raw residual spreadUseful visual clue
ConstantApproximately the same standard deviation across predictionsVertical scatter remains roughly even
ProportionalStandard deviation rises in proportion to predictionA widening band; relative spread is roughly stable
CombinedSpread includes a constant component and an increasing componentSpread does not collapse near low predictions and grows at higher predictions

Under proportional error, dividing a residual by its prediction gives a scale-free diagnostic when predictions are positive: the standard deviation of \(e_{ij}/\hat C_{ij}\) is approximately \(\sigma_p\). Under combined error, that ratio is not constant; its variance is \(\sigma_a^2/\hat C_{ij}^{\,2}+\sigma_p^2\), so the additive component matters most at low predictions. Ratios should not be used near zero, where division by a small prediction can magnify noise.

Worked Example: Proportional Spread

In a hypothetical data set, three residuals in a bin with predictions near 2 mg/L are \(-1,0,1\) mg/L. In a bin with predictions near 8 mg/L, they are \(-4,0,4\) mg/L. Calculate the spreads and compare spread relative to prediction.

Both bin means are zero. The low-bin sample standard deviation is \(\sqrt{(1+0+1)/2}=1.00\) mg/L. The high-bin sample standard deviation is \(\sqrt{(16+0+16)/2}=\sqrt{16}=4.00\) mg/L.

The ratios of sample standard deviation to representative prediction are \(1/2=0.500\) and \(4/8=0.500\). The raw spread is four times larger when prediction is four times larger, while relative spread is the same. This pattern is compatible with proportional error with \(\sigma_p\) about 0.500; the small illustrative bins cannot provide a precise estimate or test of that parameter.

Worked Example: A Combined Error Pattern

Suppose a hypothetical combined model has \(\sigma_a=3.00\) mg/L and \(\sigma_p=0.250\). Find the expected residual standard deviation near predictions of 2 mg/L and 8 mg/L, then assess two illustrative bins whose residuals are \((-3.041,0,3.041)\) mg/L and \((-3.606,0,3.606)\) mg/L.

At 2 mg/L, the model gives \(\sqrt{3.00^2+(0.250\times2)^2}=\sqrt{9+0.25}=\sqrt{9.25}=3.041\) mg/L. The first bin's sample mean is zero and its sample standard deviation is \(\sqrt{(3.041^2+0+3.041^2)/2}=3.041\) mg/L, up to rounding.

At 8 mg/L, the expected standard deviation is \(\sqrt{3.00^2+(0.250\times8)^2}=\sqrt{9+4}=\sqrt{13}=3.606\) mg/L. The second bin's sample mean is zero and its sample standard deviation is \(\sqrt{(3.606^2+0+3.606^2)/2}=3.606\) mg/L, up to rounding. The increase is modest rather than proportional: the constant component remains present at both concentrations. This constructed agreement illustrates the variance function; real binned estimates will fluctuate around it.

Diagnostics, Alternatives, and Limits

Begin by plotting raw residuals against the predictions used to calculate them and include a horizontal zero reference. Look for both a trend in the center and a change in vertical spread. Add binned means to inspect signed bias and binned standard deviations or another clearly defined spread summary to inspect dispersion. State the bin boundaries or rule and the number of observations in each bin; a spread estimate from a tiny bin should not be given the same visual weight as one based on many observations.

A raw residual plot is not the only view. Standardized residuals divide raw residuals by a model-based residual standard deviation; if that variance model is appropriate, their spread should be more nearly stable across prediction. They can help show remaining structure, but a standardized plot can conceal misspecification if the same questionable variance model is used to scale the residuals. Residuals against time can reveal time-localized structure that a prediction plot does not show. These views answer different diagnostic questions, so none replaces the others.

The interpretation of bins relies on the conditional-mean and variance assumptions. A visible nonzero binned mean is not evidence for a particular variance function: variance describes spread, while the mean describes signed bias. Conversely, a widening cloud does not by itself identify proportional error. If observations from the same subject are dependent, treating all residuals as independent can make a pattern look more convincing than it is. Summaries should therefore be read alongside the sampling structure and other diagnostics, not as independent formal tests.

Predicted concentrations are estimated, not fixed known values. Their uncertainty, and the method used to obtain individual predictions, can affect the residual pattern. A wrong structural prediction can also leave systematic residual patterns; a variance model should not be used automatically to absorb every mismatch. Concentrations near an assay's quantification limit, censored observations, or a narrow prediction range can make the visual distinction among error structures especially difficult.

A common mistake is to see a residual cloud that gets wider at higher predictions and conclude that proportional error has been proved. The correction is to ask whether the standard deviation is approximately proportional to prediction, whether a nonzero additive component remains at low predictions, and whether the pattern is stable across sensible bin choices and diagnostic views. These plots help assess compatibility with a residual structure; they do not alone establish it or replace comparing plausible models with the full data and scientific context.

Key takeaway: Read the residual center and spread separately. Binned means diagnose average signed discrepancy; binned sample standard deviations describe within-bin spread. Roughly flat, prediction-proportional, and mixed spread patterns are compatible with constant, proportional, and combined error, respectively, but finite samples and model assumptions limit the conclusion.

Check Your Understanding

Answer each question, then compare with the short solutions below.

  1. A prediction bin has residuals \(1,3,5\) mg/L. What are the bin mean and sample standard deviation, and what does the positive mean indicate?
  2. Why does adding 4 mg/L to every residual in a bin change its mean but not its sample standard deviation?
  3. A proportional-error model has \(\sigma_p=0.20\). What residual standard deviation does it imply at a prediction of 5 mg/L?
  4. What is one reason a binned standard deviation might be unrepresentative of the underlying residual standard deviation?
  5. Why is a widening raw-residual plot not sufficient by itself to prove proportional error?

Solutions. (1) The mean is \((1+3+5)/3=3\) mg/L. The sample variance is \([(1-3)^2+(3-3)^2+(5-3)^2]/2=8/2=4\) \((\mathrm{mg/L})^2\), so \(s=2\) mg/L. The positive mean says observations average 3 mg/L above predictions in this bin. (2) The mean increases by 4 mg/L, but each residual's deviation from the new mean is unchanged, so the sample standard deviation is unchanged. (3) The standard deviation is \(0.20\times5=1.00\) mg/L. (4) Finite bin size, dependence, or considerable variation in prediction within the bin can make it unrepresentative. (5) The pattern could reflect finite sampling, dependence, prediction error, or another source of changing spread; proportional error specifically predicts standard deviation increasing in proportion to prediction.