Tutorials › Pharmacokinetic-Pharmacodynamic (PK/PD) Modeling › Diagnosing Time Alignment and History-Model Misspecification

Time-Varying Covariates and Dosing History · Tutorial 502 of 598

Diagnosing Time Alignment and History-Model Misspecification

Use event-focused residual and prediction checks to distinguish possible timing and history-model problems from ordinary variability, and to guide cautious model revision.

Advanced 12 min read

What You'll Learn

  • Define event-focused residual checks for dose changes, covariate updates, and treatment gaps.
  • Interpret how a timestamp shift can create a characteristic pattern in residuals.
  • Check whether covariate interpolation is credible using withheld measurements and prediction behavior.
  • Recognize when equal cumulative doses can conceal important differences in recency.
  • Compare history representations without treating a better fit as proof of a mechanism.
  • Separate data-timeline errors from model misspecification and ordinary residual variation.

Why Diagnose the Timeline Around Events?

A model can describe average concentration or response adequately while getting the timing of a dose, covariate update, or treatment interruption wrong. Such errors are especially consequential near events: a dose taken earlier than recorded can make an otherwise plausible effect appear delayed, while an inappropriate interpolation can imply covariate values that were never observed. A dosing-history summary can also omit clinically relevant timing even when the recorded total dose is correct.

Residuals and predictions should therefore be examined against time relative to events, not only against calendar time or a pooled summary. These checks can identify patterns that deserve investigation. They do not, by themselves, prove that the event record is wrong, establish a causal explanation, or select a unique history model.

Definition: For observation \(j\) on individual \(i\), let \(y_{ij}\) be the observed response and let \(\hat{y}_{ij}\) be the model prediction at the recorded observation time, conditional on the model’s dose and covariate histories. The residual is \(e_{ij}=y_{ij}-\hat{y}_{ij}\). A positive residual means the observation is above the prediction; a negative residual means it is below. An event-focused diagnostic displays residuals or predictions against time relative to a dose change, covariate update, or treatment gap, while retaining the event and observation timestamps used to construct the histories.

What a Time-Aligned Model Assumes

A convenient general representation is \(y_{ij}=f(t_{ij},H_i(t_{ij}),z_i(t_{ij});\theta)+\epsilon_{ij}\), where \(t_{ij}\) is the observation time, \(H_i(t)\) is the modeled dose history, \(z_i(t)\) is the modeled time-varying covariate information, \(\theta\) denotes model parameters, and \(\epsilon_{ij}\) is unexplained variation. The history and covariate values supplied to \(f\) must correspond to the intended time convention. For example, a dose recorded at time \(d\) must not affect a prediction before \(d\) unless the record or model explicitly supports that interpretation.

The usual diagnostic expectation is not that every residual equals zero. Rather, after accounting for the specified error distribution and any modeled correlation, residuals should show no systematic mean pattern with time relative to events. The variance model should also be reasonably compatible with the spread of residuals across those times. These expectations assume that observations, doses, and covariates have been placed on a consistent timeline; that the prediction is calculated using information available at the relevant time; and that the model’s error and correlation assumptions are adequate for the diagnostic being used.

Before interpreting a plot, establish what each timestamp means: administration time or scheduled time, sample collection or result time, and the effective time of a covariate value. Confirm units, time zones, date changes, and whether an event is recorded as a point or an interval. For a treatment gap, distinguish the documented last administered dose from a planned dose that was not taken. The earlier material on reconstructing analysis timelines and prescribed versus administered dose is directly relevant to these checks.

Diagnostic principle: A local pattern is informative only in relation to the event definition, the prediction model, and the observation-error structure. Replication across individuals or events strengthens the case for a systematic issue; a single large residual may instead reflect ordinary variability, an atypical response, or an unrecorded event.

Why a Timestamp Shift Creates a Residual Pattern

Consider a response trajectory \(f(\tau)\) as a function of time \(\tau\) since a dose. Suppose the true event occurs at time \(d\), but the analysis uses \(d+\delta\). At calendar time \(t\), the true time since dose is \(\tau=t-d\), whereas the model uses \(\tau-\delta\). If the true mean follows \(f\), the expected residual is approximately the true mean minus the model mean:

$$ E(e\mid t)\approx f(\tau)-f(\tau-\delta) \approx \delta f'(\tau). $$

The second approximation is a first-order Taylor expansion and is most useful for a modest shift where the response curve is locally smooth. It explains why residuals can have one sign while the response is rising and another sign while it is falling. The expected sign is not universal: it depends on whether the analysis event is early or late and on the trajectory’s direction. A distinct onset, peak, or recovery pattern can make this diagnostic more visible than a pooled residual mean.

An instantaneous response model may not be appropriate for a drug whose concentration or effect changes gradually after administration. In that case, an apparent timing mismatch could instead reflect an incorrect absorption, distribution, or effect-delay structure. Event-focused checks flag where the discrepancy occurs; they do not identify which component is responsible.

Worked Example: Checking a Dose-Time Discrepancy

In a hypothetical study, a response rises after a dose recorded at hour 8. A fitted model predicts response values using that recorded time. The observed and predicted values around the event are shown below. Response is measured in arbitrary response units.

Time (h)Observed responsePrediction using recorded dose timeResidual
7.510.110.00.1
8.2512.210.51.7
8.513.011.02.0
9.013.112.01.1
10.013.213.00.2

For example, at hour 8.5, \(e=13.0-11.0=2.0\) response units. Residuals are near zero before the dose, strongly positive soon after it, and near zero again by hour 10. This localized pattern is consistent with a model that predicts the post-dose rise too late, but it does not establish that the dose timestamp is wrong.

Suppose a sensitivity check moves the dose time 0.5 hours earlier and gives predictions of 12.0, 12.8, 13.1, and 13.2 at hours 8.25, 8.5, 9, and 10, respectively. The four revised residuals are \(0.2, 0.2, 0.0,\) and \(0.0\). Their sum of squared residuals is \(0.2^2+0.2^2+0^2+0^2=0.0800\) response-units squared. Before the shift it was \(1.7^2+2.0^2+1.1^2+0.2^2=8.14\) response-units squared. The shifted prediction fits these observations better, but that improvement is not proof of the true administration time: it must be checked against source records and assessed without overlooking the extra flexibility introduced by changing the timeline.

Diagnosing Covariate Updates and Interpolation

When covariates are measured intermittently, the analysis requires a rule for assigning values between measurements or beyond their observed range. Interpolation can generate a smooth path that is convenient computationally but implausible clinically. A sudden laboratory result, a delayed data entry, or a change in measurement method can make linear interpolation particularly misleading. The earlier material on interpolating irregular covariate measurements covers the construction of such paths; here the focus is on checking their consequences.

Useful checks include plotting the observed measurements and the reconstructed path together; examining response predictions and residuals around updates; and, when feasible, withholding intermediate measurements and seeing how alternative reconstruction rules predict them. A sudden residual shift after an update can indicate a timing or interpolation problem, but it can also indicate an incorrect covariate-to-parameter relationship, delayed biological response, or a change in another variable. The model’s biological timing should not automatically be equated with the timestamp of a laboratory result.

Worked Example: Testing a Covariate Reconstruction

Suppose a hypothetical covariate is measured as 40 units at hour 0 and 100 units at hour 12. A measurement at hour 6 is withheld for a prediction check; its recorded value is 46 units. Linear interpolation between the endpoints predicts \(40+(6/12)(100-40)=70\) units at hour 6, an error of \(46-70=-24\) units. Carrying the last observation forward predicts 40 units, an error of \(46-40=6\) units.

To see how this can affect response predictions, suppose a simple illustrative model predicts \(20+0.2z\) response units for covariate value \(z\), and the observed response at hour 6 is 29.2 units. Using the interpolated \(z=70\), the prediction is \(20+0.2(70)=34.0\), giving a residual of \(29.2-34.0=-4.8\) response units. Using the carried-forward \(z=40\), the prediction is \(20+0.2(40)=28.0\), giving a residual of \(29.2-28.0=1.2\) response units.

In this hypothetical check, the carried-forward rule predicts the withheld covariate and response more closely at hour 6. One withheld point does not prove that carrying values forward is generally appropriate, nor that the response model is correct. The measurement could represent a real abrupt change, and the reconstruction rule should be assessed across relevant individuals and times, with attention to the covariate’s biological plausibility and measurement process.

When a Dose-History Summary Is Too Simple

A summary such as cumulative dose can discard the timing of administration. Two histories with the same cumulative amount may have very different recent exposure, especially when effects diminish after dosing or when interruptions and reinitiation matter. Residuals should therefore be examined against features omitted by the summary, such as time since last dose, time since a gap began, or the number and spacing of recent administrations. These plots diagnose possible lack of fit; they do not determine which alternative encoding should be used. The earlier material on cumulative and recency-weighted history and on treatment interruptions supplies the relevant concepts.

Worked Example: Equal Cumulative Dose, Different Recency

Consider two hypothetical dosing histories observed at hour 10. History A consists of a 100-unit dose at hour 0; history B consists of a 100-unit dose at hour 9. Both have cumulative dose 100 units. For illustration, define a recency-weighted history \(H(t)=\sum_k D_k\exp[-0.2(t-d_k)]\), where \(D_k\) is dose amount, \(d_k\) is its time, and the decay constant has units of inverse hours.

For history A, \(H_A(10)=100\exp[-0.2(10-0)]=100\exp(-2)=13.53\) weighted dose units. For history B, \(H_B(10)=100\exp[-0.2(10-9)]=100\exp(-0.2)=81.87\) weighted dose units. The cumulative-dose summary treats the histories as identical, whereas this illustrative recency summary does not.

Suppose the hypothetical responses are 6.35 and 13.19 units for histories A and B, respectively, and a cumulative-dose model predicts 9.77 units for both. The residuals are \(6.35-9.77=-3.42\) and \(13.19-9.77=3.42\) response units. Opposite residual signs associated with different recency despite equal cumulative dose are consistent with omitted timing information. With only two observations, however, the pattern is not persuasive evidence by itself; repeated histories, variability, and other differences between individuals must be considered.

A Practical Diagnostic Sequence

A disciplined sequence helps avoid changing the model to compensate for errors in data preparation. First inspect records and definitions; then assess whether the prediction mismatch is localized and reproducible; finally compare plausible model explanations. In particular, do not tune an event time solely to minimize residuals if the source record contradicts the change.

1
Verify event and observation records.
Check time units, time zones, administration versus prescription, sample time versus result time, and how gaps or covariate updates are represented.
2
Locate the discrepancy.
Plot observations, predictions, and residuals against time relative to each relevant event. Keep the event time and any modeled delay visible.
3
Check reproducibility and uncertainty.
Ask whether similar patterns recur across individuals or events and whether the residual scale, correlation, or sampling design could explain them.
4
Compare defensible explanations.
Test record corrections supported by source data, plausible covariate reconstructions, and history summaries that preserve potentially relevant timing. Reassess prediction and residual behavior after each change.

Alternatives, Failure Modes, and Limits

An event-relative residual plot is a focused diagnostic, not a replacement for checking the full model. A pooled residual plot can reveal broad trends but may hide patterns that occur only after a dose change. Prediction checks on withheld covariate measurements directly assess reconstruction performance where measurements are available, but they may not represent unobserved periods. Source-record review can resolve a timestamp question more directly than a fit comparison, but it cannot determine whether the response model’s time course is adequate.

Common failure modes include treating a better-fitting shifted timeline as evidence that the event truly occurred at the shifted time; interpreting one unusually large residual as systematic misspecification; ignoring repeated observations from the same individual; and applying a smooth interpolation across a known abrupt change. Model comparisons also depend on the candidate models and the data used: a more flexible history can improve in-sample fit simply by adapting more closely to those observations. Earlier material on model selection and averaging is relevant to that broader issue, but no selection metric can repair a misrecorded event or make an implausible history credible.

A practical pitfall is to say, “The residuals are positive after the dose, so the dose must have been given earlier.” The correction is: “The predictions are too low after the recorded dose, a pattern compatible with earlier administration under this model; verify the event record and consider other explanations, including an incorrect response delay or dose-effect relationship.” Diagnostics guide investigation; they do not turn residual association into causal proof.

Key takeaway: Interpret event-focused residuals jointly with the underlying records, model assumptions, and repeated evidence. A credible diagnosis explains where and when predictions fail, remains compatible with the event data, and improves relevant predictions without relying only on a more flexible in-sample fit.

Check Your Understanding

Answer each question before reading the solutions.

  1. An observed response is 18.4 units and its prediction is 20.0 units. What is the residual, and what does its sign mean?
  2. A model predicts a response rise after a dose later than the observations show. Name two distinct explanations that should be considered before changing the dose timestamp.
  3. A covariate is 30 units at hour 0 and 50 units at hour 10. What does linear interpolation predict at hour 5? Give one reason that prediction could be misleading.
  4. Two histories have equal cumulative dose, but one has a much more recent dose. Why might their responses differ under a recency-sensitive process?

Solutions. (1) \(e=18.4-20.0=-1.6\) response units; the observation is 1.6 units below the model prediction. (2) The recorded dose could be late, but the modeled absorption or response delay could also be too long; source records and model assumptions should be checked. (3) Linear interpolation gives \(30+(5/10)(50-30)=40\) units. It could be misleading if the covariate changed abruptly or the measurements do not support a linear path. (4) A recent dose can contribute more to a recency-sensitive history than an older dose, even when total administered amounts match, so the model may predict different current effects.

Clinical Biostats