Tutorials › Population Pharmacokinetics › Detecting Serial Dependence In Within-Subject Residuals

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

Detecting Serial Dependence In Within-Subject Residuals

Learn how ordered residual plots and within-subject lag correlations reveal dependence that pooled residual summaries can hide.

Intermediate 10 min read

What You'll Learn

  • Explain why residual order within each subject matters.
  • Define and calculate a within-subject lag correlation.
  • Distinguish record lags from elapsed-time lags when sampling is irregular.
  • Recognize how pooled summaries can conceal subject-level dependence.
  • Identify limitations and common failure modes of residual autocorrelation diagnostics.

Why Preserve the Order of Residuals?

A residual histogram can look balanced around zero even when the model repeatedly underpredicts and then overpredicts within the same subject. The histogram records the values but discards their order. Detecting serial dependence therefore requires looking at residuals in the sequence in which observations were collected for each subject, rather than treating all records as an unordered pool.

In population pharmacokinetics, measurements from one subject are repeated observations, often at different times after a dose or across dosing occasions. A residual at one observation may be related to the residual at the next. Such a pattern can signal that the model has not captured some time-related structure, although it does not by itself identify the cause. The useful diagnostic question is whether residuals that are close together in a subject’s observation sequence tend to move together, alternate, or otherwise show a reproducible pattern.

Definition: Let \(r_{ij}\) denote the residual for subject \(i\) at that subject’s \(j\)th observation, with observations ordered by their recorded times. Serial dependence is a relationship between residuals at different positions in the same subject’s sequence. A lag of \(k\) records compares \(r_{ij}\) with \(r_{i,j+k}\). A lag counts positions in the sequence; it does not necessarily represent a fixed elapsed time.

Use a consistent residual type and scale for the diagnostic. For example, conditional weighted residuals (CWRES) are designed to be comparable on a standardized scale under their relevant assumptions. The diagnostic here concerns their order within subjects, not whether a residual histogram is normal. Residuals from different subjects should not be connected as if one subject’s last observation were followed by another subject’s first.

Ordered Plots and Lag Correlations

An ordered residual plot places the chosen residual on the vertical axis and observation order or time on the horizontal axis, with separate sequences for subjects or clearly distinguished subject-level lines. Runs of several positive residuals followed by several negative residuals suggest persistence: nearby residuals tend to share a sign. Frequent alternation may suggest negative dependence. A plot can also reveal a trend or a repeating pattern that a single lag-one summary would not capture.

A numerical companion is the within-subject lag correlation. For one subject with \(m\) residuals, form two overlapping vectors at lag \(k\):

$$ \mathbf{x}_{i,k}=(r_{i1},\ldots,r_{i,m-k}),\qquad \mathbf{y}_{i,k}=(r_{i,1+k},\ldots,r_{im}). $$

The lag-\(k\) correlation is the ordinary sample correlation between these two vectors, provided each has nonzero variation. It is a descriptive measure of linear association between residuals \(k\) records apart. At lag one, each residual is paired with the next residual for the same subject. With short sequences, there are few pairs, so the calculated correlation can be highly unstable; a value near 1 or -1 is not, by itself, strong evidence of a general pattern.

Interpretation: A positive lag-one correlation means that, in the paired observations used to calculate it, higher residuals tend to be followed by higher residuals and lower residuals by lower residuals. A negative value means the paired values tend to move in opposite directions. Neither interpretation establishes a cause, proves model misspecification, or supplies a formal significance test.

Why Correlation Can Indicate Dependence

For a stationary residual sequence, let its mean be zero, its variance be \(\gamma(0)\), and its lag-\(k\) covariance be \(\gamma(k)=\operatorname{Cov}(r_j,r_{j+k})\). The population autocorrelation is \(\rho(k)=\gamma(k)/\gamma(0)\), when \(\gamma(0)>0\). If residuals are independent across observations, then \(\gamma(k)=0\), and hence \(\rho(k)=0\), for every positive lag. This gives the diagnostic its basic rationale: nonzero autocorrelation is incompatible with independence under these conditions.

A simple model illustrates how dependence can persist across multiple lags. Suppose a zero-mean stationary sequence follows \(r_j=\phi r_{j-1}+u_j\), where the innovations \(u_j\) have mean zero and are independent of earlier residuals. For \(|\phi|<1\), stationarity gives \(\operatorname{Var}(r_j)=\gamma(0)\). Taking covariance with \(r_{j-1}\) yields \(\gamma(1)=\phi\gamma(0)\), because \(u_j\) is uncorrelated with \(r_{j-1}\). Repeating the argument gives \(\gamma(k)=\phi\gamma(k-1)\), so \(\rho(k)=\phi^k\). Thus a positive \(\phi\) produces correlations that decay with lag, while a negative \(\phi\) produces alternating signs. This is an illustration of a possible pattern, not a reason to assume that a fitted PK model has this residual structure.

Worked Example: A Lag Correlation of One

Suppose, hypothetically, that one subject has four ordered standardized residuals \((-1,-0.4,0.2,0.8)\). At lag one, the overlapping vectors are \(\mathbf{x}=(-1,-0.4,0.2)\) and \(\mathbf{y}=(-0.4,0.2,0.8)\). Calculate their correlation and interpret it.

The means are \(\bar{x}=(-1-0.4+0.2)/3=-0.4\) and \(\bar{y}=(-0.4+0.2+0.8)/3=0.2\). After centering, both vectors are \((-0.6,0,0.6)\). Their sample correlation is

$$ r_1= \frac{(-0.6)(-0.6)+(0)(0)+(0.6)(0.6)} {\sqrt{[(-0.6)^2+0^2+(0.6)^2][(-0.6)^2+0^2+(0.6)^2]}} =\frac{0.72}{0.72}=1. $$

The later vector equals the earlier vector plus \(0.6\): \((-1,-0.4,0.2)+0.6=(-0.4,0.2,0.8)\). Adding a constant does not change correlation, so the correlation is exactly 1. This small example is mathematically exact but diagnostically weak: it uses only three lag-one pairs from one subject. It illustrates the calculation, not persuasive evidence about a population of subjects.

How Pooling Can Conceal Dependence

A pooled mean, standard deviation, or histogram ignores which residual came first and which subject produced it. Even a pooled lag-correlation calculation can mislead if different subjects have different patterns that offset one another. The calculation should preserve each subject’s adjacent pairs and should be interpreted alongside subject-level plots and correlations. It is not valid to create lagged pairs across subject boundaries.

Worked Example: Opposing Subject Patterns Cancel in a Pool

Consider hypothetical standardized residual sequences for two subjects: subject A has \((-1,0,1)\), and subject B has \((1,0,-1)\). For A, the lag-one vectors are \((-1,0)\) and \((0,1)\). Their means are \(-0.5\) and \(0.5\); after centering, both are \((-0.5,0.5)\), so their correlation is \(1\). For B, the vectors are \((1,0)\) and \((0,-1)\); after centering, they are \((0.5,-0.5)\) and \((0.5,-0.5)\), so their correlation is also \(1\). Within each sequence, the two pairs rise together.

Now pool the valid within-subject pairs without retaining subject labels. The first-vector values are \((-1,0,1,0)\), and the second-vector values are \((0,1,0,-1)\). Both pooled means equal zero. The sum of cross-products is

$$ (-1)(0)+(0)(1)+(1)(0)+(0)(-1)=0. $$

The pooled lag-one correlation is therefore zero, since both pooled vectors have nonzero variation and their cross-product sum is zero. The pooled result hides the positive within-subject pattern in this constructed example. Each individual correlation is based on only two pairs and is itself extremely unstable; the point is that a pooled value can conceal structure, not that these tiny sequences establish a reliable finding.

Repeated sampling can make a similar issue visible in practice. If every subject contributes a few observations, pooling all residuals may provide a large-looking collection while obscuring whether patterns are consistent within subjects, vary by subject, or cancel. A useful display preserves the sequence for each subject. Where many subjects are available, summarize the distribution of subject-level lag correlations or the frequency of visible patterns, while acknowledging that subjects with different sequence lengths contribute correlations of different precision.

Irregular Times, Higher Lags, and Diagnostic Limits

A lag of one means “the next recorded observation,” not “one hour later.” If one pair is separated by 20 minutes and another by 12 hours, they are both lag-one pairs in an ordinary sequence-based calculation. When time gaps vary substantially, show actual elapsed time in the ordered plot and inspect whether apparent dependence changes with the gap. A record-lag correlation alone may combine pairs with very different temporal separations; it should not be described as a correlation at a fixed time interval.

Lag one is often a natural first check, but it is not sufficient for every pattern. Alternating residuals can have weak lag-one correlation and strong negative correlation at lag two. Conversely, examining many lags in short subject sequences creates noisy summaries. Higher-lag estimates use fewer pairs, so they become less stable as the lag increases. A single numerical summary should not replace visual inspection.

Worked Example: Lag One Misses an Alternating Pattern

Suppose, hypothetically, that a subject’s ordered residuals are \((-1,0,1,0,-1)\). At lag one, \(\mathbf{x}=(-1,0,1,0)\) and \(\mathbf{y}=(0,1,0,-1)\). Both means are zero, and the cross-product sum is \((-1)(0)+(0)(1)+(1)(0)+(0)(-1)=0\). Both vectors have a sum of squared deviations of \(2\), so \(r_1=0/\sqrt{2\cdot2}=0\).

At lag two, the vectors are \((-1,0,1)\) and \((1,0,-1)\). The second vector is the negative of the first, so after centering they remain exact negatives and \(r_2=-1\). Thus the zero lag-one correlation does not mean that the sequence has no ordered pattern. Again, the sequence is too short to support a stable general conclusion; it demonstrates why plots and more than one relevant lag may be informative.

Interpreting Patterns and Comparing Approaches

An ordered plot is usually the most direct first diagnostic because it retains timing, subject identity, runs, trends, and abrupt changes. Lag correlations condense selected aspects of that display into numbers, making patterns easier to compare but discarding some detail. Pooled summaries such as a residual mean or histogram answer different questions about the marginal distribution and cannot substitute for an ordered within-subject assessment.

A model-based residual correlation structure is another approach: it represents dependence explicitly as part of a statistical model. That is not the same as diagnosing dependence in residuals from a model that assumes conditional independence. A visible pattern may motivate checking model structure, sampling times, dose records, or omitted time-related features; it does not alone determine which change is warranted. Any alternative structure needs its own justification and evaluation.

Interpret the evidence cautiously. Serial patterns can arise from misspecified structural dynamics or residual-error assumptions, but can also reflect influential observations, sparse sampling, timing discrepancies, or a few subjects with unusual sequences. If residuals have strong shrinkage or are otherwise highly dependent on estimated individual quantities, their apparent patterns may also be difficult to interpret. Do not declare a model adequate simply because an aggregate correlation is near zero, and do not automatically modify the model in response to one striking short sequence.

1
Choose a residual scale.
Use one residual type consistently, and identify the subject and observation order for every value.
2
Plot sequences in order.
Look for runs, alternation, trends, and changes within subjects; show actual times when intervals are uneven.
3
Calculate selected lag correlations.
Construct lagged vectors within subjects only, report the number of contributing pairs, and treat short-sequence estimates as uncertain.
4
Compare subjects, not only pooled values.
Assess whether patterns recur, differ, or cancel, then consider plausible explanations without treating a diagnostic as a causal conclusion.

Common Mistakes

  • Ignoring order. A centered histogram does not establish independence. Keep the observation sequence visible.
  • Joining subjects. The final residual for one subject and the first for another do not form a meaningful lagged pair.
  • Calling record lag elapsed time. Lag one means the next record, even when time gaps differ. Use actual times to assess the role of interval length.
  • Overinterpreting a perfect correlation. A correlation of 1 from two or three pairs is mathematically possible and practically unstable.
  • Taking a pooled zero as proof of no dependence. Subject-specific patterns can cancel in a pooled calculation. Inspect the separate sequences.
  • Treating correlation as a diagnosis of cause. Residual dependence is a signal to investigate, not proof of a particular missing mechanism or error model.
Key takeaway: Serial dependence is an ordered, within-subject property. Preserve subject identity and observation order, use lag correlations as descriptive summaries alongside plots, and be especially cautious with short or irregularly sampled sequences and pooled results.

Check Your Understanding

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

  1. A subject has residuals \((-0.5,0.1,0.7)\). What does a lag-one pair compare, and how many pairs are available?
  2. Why can a pooled lag-one correlation be zero even when subjects show within-subject patterns?
  3. In irregular sampling, what does lag one mean, and what additional information should be checked?
  4. Why does a lag-one correlation of zero not rule out every ordered pattern?

Solutions. (1) It compares the first with the second residual and the second with the third; there are two pairs. (2) Different subject-level patterns can cancel when pairs are pooled, so retain subject identities and inspect individual sequences. (3) It means the next recorded observation, not a fixed duration; check actual elapsed times and whether patterns vary with the time gap. (4) A pattern may occur at another lag, as in an alternating sequence; inspect ordered plots and relevant higher lags while accounting for their greater instability.

Clinical Biostats