Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Outlier Detection In Longitudinal Measurements

Model Diagnostics · Tutorial 601 of 697

Outlier Detection In Longitudinal Measurements

Use standardized residuals and robust summaries across visits to identify unusual biomarker values and recognize when a subject’s trajectory, rather than one measurement, may be poorly represented.

Advanced 10 min read

What You'll Learn

  • Define standardized conditional residuals for repeated biomarker measurements.
  • Use absolute-residual thresholds as screening flags, not automatic declarations of outliers.
  • Calculate robust subject-level summaries and interpret them alongside visit-level residuals.
  • Distinguish an isolated extreme from a persistent signed trajectory departure.
  • Recognize how variance misspecification, dependence, and model fitting can distort flags.
  • Explain why residual screening does not establish that a measurement is erroneous.

Why Screen Longitudinal Measurements?

A single biomarker value far from its fitted value can be a recording error, a genuine transient change, or a symptom of a model that does not capture the subject’s trajectory. Repeated measurements make the distinction more informative: one isolated extreme differs from a sequence of residuals that remain unusually large or have the same sign. Outlier detection in longitudinal data is therefore a screening and interpretation task, not a rule for automatically deleting observations.

The aim here is to identify unusual measurements relative to a fitted longitudinal submodel, then summarize residual evidence across visits without allowing one extreme point to dominate every subject-level assessment. The earlier material on standardized conditional residuals for Gaussian markers provides the basic residual idea; this tutorial applies it to outlier screening and emphasizes what subject-level patterns can and cannot establish.

Model and Residuals for Screening

Let \(Y_{ij}\) denote the biomarker measurement for subject \(i\) at visit time \(t_{ij}\), for \(j=1,\ldots,n_i\). Write the longitudinal model as

$$ Y_{ij}=m_i(t_{ij};b_i)+\varepsilon_{ij}, $$

where \(m_i(t_{ij};b_i)\) is the fitted conditional mean given subject-specific random effects \(b_i\), and \(\varepsilon_{ij}\) is the measurement-level error. In a joint model, the longitudinal submodel is part of the larger model for the biomarker and event time; this screening concerns the longitudinal measurements, not event-component residuals.

Definition: A standardized conditional residual for measurement \(j\) on subject \(i\) is the observed value minus its fitted conditional mean, divided by its estimated conditional residual standard deviation: $$ r_{ij}=\frac{Y_{ij}-\widehat m_i(t_{ij};\widehat b_i)}{\widehat s_{ij}}. $$ Here \(\widehat s_{ij}\) is the estimated residual standard deviation under the fitted longitudinal model. For a homoscedastic Gaussian model without a leverage adjustment, \(\widehat s_{ij}=\widehat\sigma\). If the fitting method supplies a prediction-error or leverage adjustment, use the corresponding standardized residual definition consistently.

A positive residual means the observed biomarker is above its fitted conditional mean; a negative residual means it is below. Standardization expresses the discrepancy in residual standard-deviation units, so a residual of \(3\) is three such units above the fitted value. Under a correctly specified Gaussian model with known parameters, independent errors conditional on \(b_i\), and the correct conditional mean and variance, the error divided by its standard deviation has a standard normal distribution. In practice, model parameters and random effects are estimated, so the fitted residuals need not be independent standard normal variables; the reference is approximate and depends on the fitting procedure.

Before interpreting a large residual, check that the model’s conditional mean and variance are suitable for the observations being screened. The simple reference above presumes the residual standard deviation is correctly specified and that the conditional error distribution is adequately represented. If residual variance changes over time or depends on covariates, a single \(\widehat\sigma\) can make ordinary observations appear extreme in high-variance regions and conceal unusual values in low-variance regions. If errors are serially dependent, a sequence of same-sign residuals may partly reflect that dependence rather than a trajectory defect. The earlier material on residual autocorrelation, heteroscedasticity, and trajectory misspecification addresses those patterns; they should be considered before treating a threshold crossing as evidence of an unusual measurement.

Worked Example: Standardizing One Biomarker Value

Suppose a hypothetical subject has an observed biomarker value of \(12.4\) units at a visit. The fitted conditional mean is \(10.8\) units and the estimated residual standard deviation is \(0.8\) units. Assume the fitted model uses a constant residual standard deviation at this visit and no additional leverage adjustment is required.

The conditional residual is \(12.4-10.8=1.6\) units. Its standardized value is

$$ r_{ij}=\frac{12.4-10.8}{0.8} =\frac{1.6}{0.8}=2.0. $$

The measurement is two estimated residual standard deviations above its fitted conditional mean. It is worth inspecting in context, but this calculation alone does not show that it is erroneous or that it meets any universal definition of an outlier. The interpretation also depends on whether the model’s mean and variance are credible at this visit and on how many measurements are being screened.

Screening Measurements and Subjects

A common first screen is to flag measurements with large absolute standardized residuals. For example, \(|r_{ij}|>3\) is sometimes used as a heuristic flag under an approximately standard normal reference. It is not a formal significance test, a guaranteed false-positive rate, or a universal cutoff. With many measurements, even a small per-measurement chance of crossing a threshold can yield several flags. Dependence among visits also affects how often flags occur together. A flag is a prompt to investigate the value, its data record, and the model fit.

To summarize a subject’s residuals, use more than the largest absolute residual. Let \(R_i=(r_{i1},\ldots,r_{in_i})\). Useful summaries include the maximum absolute residual, the count of threshold exceedances, and robust measures such as the median absolute residual and median signed residual:

$$ A_i=\operatorname{median}_{j}|r_{ij}|,\qquad S_i=\operatorname{median}_{j}(r_{ij}),\qquad K_i(c)=\sum_{j=1}^{n_i} I(|r_{ij}|>c). $$

Here \(A_i\) describes a typical residual magnitude, \(S_i\) its typical direction, and \(K_i(c)\) counts measurements beyond a chosen screening cutoff \(c\). The median absolute deviation around the subject’s median residual, \(D_i=\operatorname{median}_j|r_{ij}-S_i|\), is another robust summary of within-subject spread. These summaries have different purposes: a large \(A_i\) suggests that residual magnitudes are often elevated, while a large \(|S_i|\) suggests that residuals are persistently shifted in one direction. Neither summary replaces inspecting residuals against visit time.

A robust summary is relatively resistant to one extreme value, which is useful when trying to identify a persistent pattern rather than simply rediscover the largest single measurement. But it can also hide a genuine one-time anomaly: with many visits, one extreme may barely change the median. That is why subject-level summaries and measurement-level flags should be reviewed together.

Worked Example: An Isolated Extreme Versus a Persistent Shift

Consider two hypothetical subjects, each with five standardized conditional residuals. For subject A the residuals are \(0.1,-0.2,0.0,0.2,4.1\). For subject B they are \(1.4,1.6,1.5,1.7,1.3\). Assume the same screening reference is appropriate at all ten visits.

For subject A, the absolute residuals in order are \(0.1,0.2,0.0,0.2,4.1\). Sorting them gives \(0.0,0.1,0.2,0.2,4.1\), so \(A_A=0.2\). The signed residuals sorted are \(-0.2,0.0,0.1,0.2,4.1\), giving \(S_A=0.1\). At cutoff \(c=3\), \(K_A(3)=1\). The maximum absolute residual is \(4.1\), but the typical magnitude and signed median are small. This is the pattern of one isolated extreme in an otherwise unremarkable set of residuals.

For subject B, the absolute residuals are \(1.4,1.6,1.5,1.7,1.3\), which sort to \(1.3,1.4,1.5,1.6,1.7\). Thus \(A_B=1.5\). The signed residuals sort to \(1.3,1.4,1.5,1.6,1.7\), giving \(S_B=1.5\), while \(K_B(3)=0\). No measurement crosses the heuristic cutoff, but every residual is positive and the typical residual is appreciably shifted upward.

These summaries suggest different follow-up questions. For A, inspect the record and visit corresponding to \(4.1\), and check whether it is a plausible transient value or a data problem. For B, examine residuals against time and the fitted trajectory: the consistent positive pattern may indicate a subject-specific departure not captured by the fitted mean. Neither pattern proves an error or identifies its cause.

Why the Pattern Across Visits Matters

An unusually large residual and a persistently unusual trajectory are not the same diagnostic finding. The distinction follows from looking at residual magnitude, sign, and time order together. An isolated large \(|r_{ij}|\) with neighboring residuals near zero is compatible with a single measurement anomaly, but also with a real short-lived biological change. Repeated residuals with similar signs suggest that the fitted conditional mean may be systematically high or low for that subject or period. A changing pattern—for example, small residuals early and increasingly positive residuals later—may point to a time-dependent mismatch rather than one aberrant observation.

A short justification explains the role of standardization. If the model has the form \(Y_{ij}=m_i(t_{ij};b_i)+\varepsilon_{ij}\), with conditional mean \(E(\varepsilon_{ij}\mid b_i)=0\) and conditional variance \(\operatorname{Var}(\varepsilon_{ij}\mid b_i)=s_{ij}^2\), then

$$ E\!\left(\frac{\varepsilon_{ij}}{s_{ij}}\middle|b_i\right)=0,\qquad \operatorname{Var}\!\left(\frac{\varepsilon_{ij}}{s_{ij}}\middle|b_i\right)=1. $$

The first equality follows by dividing the zero conditional mean by \(s_{ij}\); the second follows because the variance of a constant multiple is the squared constant times the variance: \(s_{ij}^{-2}s_{ij}^2=1\). Thus standardization puts residuals on a common scale when the conditional variance model is right. It does not make residuals independent, correct a wrong mean model, or make estimated residuals exactly standard normal.

Worked Example: Summarizing a Consistent Direction

A hypothetical subject has residuals at five visits, in time order, of \(-1.2,-0.8,-0.5,0.9,1.4\). Assume conditional standardization is adequate and use \(c=3\) only as a screening threshold.

The sorted signed residuals are \(-1.2,-0.8,-0.5,0.9,1.4\), so the median signed residual is \(S_i=-0.5\). The absolute residuals sort to \(0.5,0.8,0.9,1.2,1.4\), so \(A_i=0.9\). No visit exceeds the threshold, and the signs are not consistently positive or negative. The sequence changes from negative to positive, so it suggests a time-pattern question rather than one isolated extreme or a constant signed shift.

For comparison, if these residuals had instead been \(-1.2,-1.0,-0.9,-0.8,-0.7\), then \(S_i=-0.9\) and \(A_i=0.9\), with all five residuals negative. That persistent direction would be stronger evidence to inspect whether the fitted conditional trajectory is systematically above this subject’s observed trajectory. The numerical summaries are screening clues, not a causal explanation or a definitive classification.

Practical Review and Common Pitfalls

A defensible review combines the numerical flags with the observed data, visit times, fitted trajectory, and model assumptions. First verify the measurement, units, visit label, and any data-processing steps. Then compare the value with neighboring observations and the subject’s broader course, without assuming that abrupt biological change is impossible. Next consider whether the conditional mean and residual variance are plausible at that time. If the pattern is repeated or time-ordered, inspect the relevant longitudinal residual diagnostics before concluding that the subject or measurement is unusual.

  • Calling every threshold crossing an outlier. A cutoff such as 3 is a screening convention, not a universal decision rule. Review multiplicity, dependence, model fit, and clinical plausibility.
  • Using only the subject’s maximum residual. A maximum identifies a candidate measurement but does not distinguish a lone spike from repeated departures. Pair it with robust summaries and the time-ordered residual sequence.
  • Calling a persistently shifted subject a set of bad measurements. Repeated same-sign residuals may reflect a trajectory feature the model does not represent. Investigate the pattern rather than treating each value as an independent error.
  • Assuming standardization fixes model misspecification. Dividing by an estimated standard deviation is useful only if that standard deviation is appropriate. Wrong variance, dependence, or mean structure can produce misleading flags.
  • Deleting a flagged observation without justification. Removing a genuine value can distort the fitted model and its conclusions. Correct a record only when the data source supports the correction; otherwise document and assess the result with the observation retained and, when appropriate, in a clearly described sensitivity analysis.

Compared with raw residuals, standardized residuals make discrepancies more comparable across visits with different modeled variances. Compared with a maximum-residual-only screen, robust subject-level summaries are less dominated by one extreme and can highlight persistent departures. Neither approach is a substitute for the other: the first helps identify individual candidate values, while the second helps characterize patterns across a subject’s visits. Residual plots and checks for autocorrelation, heteroscedasticity, or trajectory misspecification address broader model adequacy questions. These methods are limited by sparse visits, estimated random effects, and the possibility that a real transient change resembles a measurement error. Outlier screening itself does not determine which explanation is correct.

Key takeaway: Use standardized conditional residuals to screen individual measurements, and robust signed and absolute summaries to describe patterns across visits. Interpret flags in time order and under the fitted model’s assumptions; a residual identifies a discrepancy, not its cause.

Check Your Understanding

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

  1. A measurement is \(8.7\) units, its fitted conditional mean is \(7.5\) units, and its estimated residual standard deviation is \(0.4\) units. What is its standardized residual, and how should its sign be interpreted?
  2. One subject has residuals \(-0.1,0.2,0.0,-0.2,3.8\). What pattern would the maximum absolute residual and median absolute residual reveal?
  3. Why can repeated positive residuals be more informative about trajectory fit than a single residual with a large absolute value?
  4. Give two reasons a threshold such as \(|r_{ij}|>3\) should not be treated as an automatic declaration that a biomarker value is erroneous.

Solutions. (1) \(r=(8.7-7.5)/0.4=1.2/0.4=3.0\). The observation is three estimated residual standard deviations above its fitted conditional mean; this is a screening flag, not proof of error. (2) The maximum absolute residual is \(3.8\). The absolute values sort to \(0.0,0.1,0.2,0.2,3.8\), so the median absolute residual is \(0.2\). Together they indicate one isolated extreme among otherwise small residuals. (3) Repeated positive residuals suggest the fitted conditional mean may be systematically below the observed trajectory over several visits, whereas one large value may be transient or erroneous. The pattern still requires checking the mean model and dependence assumptions. (4) The cutoff is a heuristic rather than a universal test, and screening many possibly dependent measurements can produce flags even when the model is adequate. Also, misspecified variance or mean structure can create misleading threshold crossings.

Clinical Biostats