Tutorials › Population Pharmacokinetics › Residual Patterns Across Continuous Covariates

Diagnostics: Goodness of Fit and Shrinkage · Tutorial 338 of 599

Residual Patterns Across Continuous Covariates

Use residual plots, smooth trends, and carefully chosen covariate strata to detect patterns that may indicate remaining model bias.

Intermediate 10 min read

What You'll Learn

  • Plot residuals against continuous covariates using clear units and adequate data support.
  • Interpret smooth curves as descriptive summaries of possible residual trends.
  • Use covariate strata to check whether a pattern is robust to uneven data density.
  • Distinguish a curved trend from a weak linear association.
  • Recognize how repeated measurements, sparse regions, and covariate imbalance can mislead.
  • Separate residual diagnostics from formal covariate selection.

Why Examine Residuals Across Covariates?

A population pharmacokinetic model may describe the overall concentration data reasonably well while still showing systematic errors for patients with particular characteristics. For example, predictions could tend to be too high among people with low renal function and too low among those with high renal function. A residual plot against renal function can expose that pattern even if a plot against time or predictions appears unremarkable.

The purpose is diagnostic: ask whether residuals vary systematically with a continuous covariate, such as body weight, renal function, or age. A visible trend can point to a part of the model or data that deserves investigation. It does not, by itself, establish a causal explanation or prove that the covariate should be added to the model.

Definition: A residual-versus-covariate diagnostic plots a model residual for an observation against the value of a continuous covariate associated with that observation. Under an adequately specified model, residuals should not show a persistent systematic trend with that covariate, after accounting for the model and the way the residuals are constructed.

Use a residual type appropriate to the diagnostic question. For instance, conditional weighted residuals (CWRES) are scaled residuals intended to make observations with different prediction uncertainty more comparable. Their construction and interpretation depend on the fitted model and its assumptions. A residual pattern is evidence to investigate, not an automatic model verdict: residuals from the same individual may be related, the covariate may also vary with time, and the ends of the covariate range may have little data.

Reading the Shape of a Trend

Start with a scatterplot of residuals against the covariate, with units shown on the horizontal axis and a reference line at zero on the vertical axis. A smooth curve can help summarize the central direction of a cloud without assuming that the trend is a straight line. Read it as a descriptive guide to the data, not as a fitted pharmacokinetic relationship or a formal hypothesis test. Its appearance can depend on how it is smoothed, especially where observations are sparse.

A curve that stays near zero is consistent with little obvious residual trend over the well-supported part of the covariate range. A curve that rises or falls suggests that residuals change on average across that range. Curvature can reveal a pattern that a straight-line summary would not capture. The direction of the residual trend should be interpreted according to the residual sign convention: for a residual defined as observed minus predicted, positive values indicate observations above predictions; other conventions may reverse that interpretation.

Stratified summaries provide a complementary view. Divide the covariate range into a small number of clinically interpretable intervals and calculate the number of observations and mean residual in each. This can make a broad trend easier to communicate, but cut points matter. Wide intervals can conceal curvature, narrow intervals can be noisy, and unequal numbers of observations make the summaries have unequal precision. Always show or report the number of observations in each interval.

Worked Example: Residual Trend Across Body Weight

In a hypothetical diagnostic data set, mean CWRES are summarized at five body weights. The listed means are illustrative, and assume that each weight has comparable data support.

Body weight (kg)Mean CWRES
50-0.80
60-0.40
700.10
800.50
900.80

The mean weight is \(70\) kg. The mean of these five residual summaries is \( (-0.80-0.40+0.10+0.50+0.80)/5=0.04 \) CWRES. To quantify the linear direction descriptively, the least-squares slope is the centered cross-product sum divided by the centered weight-square sum:

$$ \hat{\beta} = \frac{\sum (w_i-\bar{w})(r_i-\bar{r})} {\sum (w_i-\bar{w})^2} = \frac{41}{1000} = 0.0410\ \text{CWRES/kg}. $$

For example, the numerator is \( (-20)(-0.84)+(-10)(-0.44)+(0)(0.06)+(10)(0.46)+(20)(0.76)=41 \); the denominator is \(400+100+0+100+400=1000\) kg². The positive slope and steadily increasing means indicate that residuals tend to be more positive at higher weights in this hypothetical summary. This is a diagnostic pattern to investigate, not evidence that weight causes the residual change or that a particular covariate model is warranted. The five summaries also cannot show how much within-weight variability exists, so the underlying observations and data density remain important.

Curvature Can Be Missed by a Straight Line

A useful diagnostic should not reduce every pattern to a correlation or a straight-line slope. Consider a hump-shaped pattern: residuals are negative at the low and high ends of age, but positive in the middle. A linear trend may be weak even though the curve is visually meaningful. Conversely, a slight nonzero slope does not rule out curvature.

Worked Example: A Hump Across Age

Suppose a hypothetical data set has one summarized residual at each of four ages. These values are for illustration only.

Age (years)Mean CWRES
20-0.90
400.50
600.30
80-0.70

The mean age is \(50\) years and the mean residual is \(-0.20\) CWRES. Centered ages are \(-30,-10,10,30\) years; centered residuals are \(-0.70,0.70,0.50,-0.50\) CWRES. Therefore:

$$ \hat{\beta} = \frac{(-30)(-0.70)+(-10)(0.70)+(10)(0.50)+(30)(-0.50)} {(-30)^2+(-10)^2+(10)^2+(30)^2} = \frac{4}{2000} = 0.00200\ \text{CWRES/year}. $$

The linear association is weak but not exactly zero. The residual summaries are negative at 20 and 80 years and positive at 40 and 60 years, so a smooth curve could show a hump that the linear slope does not describe. The slope and the curve answer different descriptive questions: the slope summarizes average linear change, while the smooth curve can reveal a changing direction. Neither calculation establishes a statistically significant effect, and these four points alone provide very limited information about the shape in between.

This illustrates a short justification for plotting a smooth trend in addition to considering a straight-line summary. A straight line can represent only a constant direction of change. If the underlying conditional mean residual \(m(x)\) bends, one slope compresses that shape into a single average direction. A pattern with an upward section and a downward section can consequently produce a small slope even though \(m(x)\) departs from zero over substantial portions of the covariate range. The plot preserves more of the shape, while remaining a visual diagnostic rather than a formal test.

Using Strata Without Hiding the Data

Strata are useful when the covariate distribution is uneven or a reader needs a compact summary. Choose intervals with sensible interpretation and enough observations to make each summary informative. Do not interpret adjacent means as precise contrasts when their data support differs greatly, and do not let a few extreme covariate values dictate the apparent pattern.

Worked Example: Renal Function Strata

A hypothetical model evaluation groups observations by estimated glomerular filtration rate (eGFR), measured in mL/min/1.73 m². The table gives the number of observations and mean CWRES in each interval.

eGFR interval (mL/min/1.73 m²)Number of observationsMean CWRES
Below 308-0.65
30 to below 6020-0.30
60 to below 90360.05
90 or above120.55

The means increase from negative to positive across the displayed intervals. A weighted mean of these stratum summaries is \( [8(-0.65)+20(-0.30)+36(0.05)+12(0.55)]/76=-2.8/76=-0.0368 \) CWRES. The overall mean is close to zero, but that does not remove the pattern: negative residuals in lower eGFR strata and positive residuals in higher strata can cancel in the aggregate. The first and last intervals contain relatively few observations, so their means may be less stable than the middle summaries. Inspect the individual points and a smooth trend before concluding that the change is consistent across the full range.

Stratification is not the same as treating a continuous covariate as categorical in the model. Here, intervals are a display device for checking residual behavior. They can clarify a broad pattern, but they discard within-interval ordering and may make a gradual trend look like abrupt thresholds. For that reason, compare stratum means with the scatterplot and smooth curve rather than relying on a table alone.

Assumptions, Diagnostics, and Alternatives

Interpret the plot with the residual definition and model context in view. The covariate value should be correctly matched to the observation: for example, a time-varying renal measure should correspond to the relevant sampling occasion, not automatically to a baseline value. A meaningful diagnostic also requires enough observations across the range and residuals whose scaling is appropriate for the model. If data are concentrated in a narrow region, a curve near the edges may be driven by very few observations.

Repeated measurements create another limitation. A plot with every concentration can give individuals with many samples more visual weight than individuals with few samples. Residuals within a subject are not generally independent, so a dense cloud should not be mistaken for an equally large independent sample. Check whether the trend is driven by a small number of subjects, and, where useful, compare the overall plot with subject-level summaries or panels. This is a robustness check, not a replacement for the observation-level diagnostic.

A continuous-covariate plot complements rather than replaces other checks. Residuals versus time after dose can reveal a time-dependent misspecification; residuals versus predictions can reveal scale-dependent error. A trend against weight or age may overlap with those patterns if sampling times, doses, or other characteristics differ across covariate values. Stratifying can help expose such imbalance, but a residual plot alone cannot identify its cause. Formal covariate selection is a separate inferential and modeling task, not the conclusion of this diagnostic.

Warning signs include a persistent smooth curve away from zero, ordered stratum means with adequate support, a pattern limited to one end of the range, or a trend that disappears when a few highly sampled individuals are examined separately. Each calls for follow-up: check data coding and units, inspect relevant observations and predictions, and consider whether time, dosing, or model structure could account for the pattern. A curve near zero is reassuring only over the part of the covariate range with sufficient data; it is not proof that the model is correct.

Common Mistakes

  • Calling a weak slope “no pattern.” A small linear association can coexist with a clear curved trend. Inspect the scatter and smooth curve as well as any straight-line summary.
  • Taking a smooth curve as a test result. Its appearance depends on data density and smoothing choices. It is a descriptive aid, not a p-value or proof of covariate effect.
  • Ignoring stratum sizes. A mean based on a few observations is less stable than one based on many. Display counts and interpret sparse intervals cautiously.
  • Reading an overall mean as evidence of no bias. Positive and negative residual trends can cancel in an aggregate mean, as the renal-function example shows.
  • Turning a diagnostic into a model-selection rule. A residual trend motivates investigation; it does not establish causation or dictate a covariate term.
Key takeaway: Examine residuals across a continuous covariate with the raw scatter, a descriptive smooth curve, and, when useful, supported strata. Look for systematic shape, check data density and repeated-subject influence, and treat any pattern as a diagnostic clue rather than a covariate-selection decision.

Check Your Understanding

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

  1. A residual curve rises across body weight but bends downward near the highest weights. Why might a single straight-line slope be inadequate?
  2. Two renal-function strata have mean CWRES of \(-0.4\) and \(0.5\), based on 6 and 60 observations, respectively. What should be reported and why should the first mean be interpreted cautiously?
  3. A plot of residuals against age appears flat overall, but most observations are concentrated between 40 and 60 years. What limitation should be stated?
  4. Why can a near-zero overall mean residual coexist with a trend across covariate strata?

Solutions. (1) A single slope summarizes only average linear change and cannot represent a curve whose direction changes; inspect the observed points and smooth pattern. (2) Report both counts and means. The \(-0.4\) mean is based on only 6 observations and is likely less stable; the difference alone is not a formal comparison. (3) The diagnostic has limited support outside 40–60 years, so an apparently flat curve there cannot rule out a trend at the sparsely observed extremes. (4) Positive and negative stratum means can cancel when averaged. A weighted average near zero therefore does not imply that residuals are near zero throughout the covariate range.

Clinical Biostats