Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Subject-Level Residual Summaries For Repeated Measures

Model Diagnostics · Tutorial 596 of 697

Subject-Level Residual Summaries For Repeated Measures

Learn to use subject-level residual summaries to identify patients whose repeated biomarker measurements depart systematically from their fitted longitudinal trajectories.

Advanced 10 min read

What You'll Learn

  • Define subject-specific residuals relative to a fitted longitudinal trajectory.
  • Calculate and interpret a patient’s mean residual and sample residual variance.
  • Count sign runs in measurement-time order and compare with a simple reference expectation.
  • Recognize how visit count, estimated parameters, and event-related observation affect interpretation.
  • Distinguish these summaries from formal tests and from residual-autocorrelation analysis.

Why Summarize Residuals by Patient?

A residual plot can show whether a longitudinal model fits the data overall, but an overall display can conceal patient-specific departures. One patient’s measurements may repeatedly lie above the fitted trajectory, while another’s residuals may alternate around zero. Summaries computed separately for each patient help locate these patterns and direct a closer review of the fitted longitudinal component.

The goal is diagnostic, not to label a patient as abnormal based on a single number. A subject-level residual mean captures the direction of average departure; a residual variance summarizes the size of departures around that patient’s mean; and a sign-run count describes whether positive and negative residuals are interspersed or clustered in measurement-time order. These summaries complement the marginal and conditional residuals introduced in earlier material, but their interpretation depends on how the residuals were constructed.

Definition: Let \(Y_{ij}\) be subject \(i\)’s biomarker measurement at visit \(j\), recorded at time \(t_{ij}\), for \(j=1,\ldots,n_i\). Let \(\widehat m_i(t_{ij})\) be the fitted longitudinal mean at that time, using the chosen conditional or marginal prediction. The corresponding residual is \(e_{ij}=Y_{ij}-\widehat m_i(t_{ij})\). The subject-level residual mean is \(\bar e_i=n_i^{-1}\sum_{j=1}^{n_i}e_{ij}\), and, when \(n_i\geq2\), the subject-level sample residual variance is \(s_{e,i}^2=(n_i-1)^{-1}\sum_{j=1}^{n_i}(e_{ij}-\bar e_i)^2\). A sign run is a maximal consecutive sequence of positive residuals or a maximal consecutive sequence of negative residuals in measurement-time order.

Assumptions and Choice of Residual

For a Gaussian longitudinal component, a useful working model is \(Y_{ij}=m_i(t_{ij})+\epsilon_{ij}\), where \(m_i(t_{ij})\) is the subject-specific mean trajectory represented by the fitted model. The basic reference interpretation of residual means and variances supposes that, conditional on the modeled trajectory and covariates, the errors have mean zero and a common variance \(\sigma^2\). The simplest reference also supposes independent errors across visits. These are assumptions to assess, not properties guaranteed by computing residuals.

The fitted mean must match the diagnostic question. A conditional fitted trajectory accounts for the subject’s estimated random effects; its residuals ask whether the measurements depart from that subject-specific fitted trajectory. A marginal fitted trajectory does not condition on the estimated random effects and answers a different question. A subject with a large estimated random intercept can have large deviations from the population trajectory but small residuals from a conditional trajectory. State which residual is being summarized, and do not interpret these two comparisons as interchangeable.

When measurement-error scales differ by visit or by subject, raw residual variances are not directly comparable. If a relevant residual standard deviation estimate is available, standardized residuals can be formed as \(r_{ij}=e_{ij}/\widehat\sigma_{ij}\); their variance can then be compared with the approximate unit-scale reference. Standardization does not fix an incorrect mean model, dependence, or a poorly estimated scale. Residuals also use estimated model parameters, and conditional predictions may use the same subject’s measurements. Consequently, idealized expectations provide diagnostic benchmarks, not exact finite-sample guarantees for each patient.

Mean and Variance Summaries

Under a correctly specified mean trajectory and zero-mean errors, the expected residual mean is approximately zero. A positive \(\bar e_i\) means the observed measurements average above the chosen fitted trajectory; a negative value means they average below it. Under independent errors with variance \(\sigma^2\), the unadjusted mean of \(n_i\) errors has variance \(\sigma^2/n_i\). Thus a mean based on two visits is much less stable than one based on ten. In fitted models, this simple variance is only a reference because parameter estimation and prediction of random effects can change the residual behavior.

The sample residual variance measures spread around \(\bar e_i\), not average departure from the fitted trajectory. It can be large even when the residual mean is near zero, for example when positive and negative errors are both substantial. Conversely, a patient can have a clearly nonzero residual mean and little spread if all residuals are similarly shifted. When \(n_i=1\), the sample variance is undefined; when \(n_i\) is small, it is highly uncertain.

Worked Example: A Patient’s Average Residual

Suppose a hypothetical patient has four biomarker measurements, and the conditional fitted values yield residuals of \(0.6\), \(0.4\), \(0.8\), and \(-0.2\) mg/L. The residual mean is

$$ \bar e_i=\frac{0.6+0.4+0.8-0.2}{4} =\frac{1.6}{4}=0.400\text{ mg/L}. $$

The average observed measurement is therefore \(0.400\) mg/L above this patient’s fitted conditional trajectory. This is a descriptive departure, not by itself evidence that the model is misspecified: there are only four visits, the residuals have sampling variation, and the trajectory was estimated. The negative residual at the final visit also shows why the mean should be read alongside the sequence of residuals.

Worked Example: Residual Variance Around the Patient Mean

For a second hypothetical patient, suppose the residuals are \(-1.0\), \(0.0\), \(1.0\), and \(2.0\) mg/L. Their mean is \((-1+0+1+2)/4=0.500\) mg/L. The deviations from that mean are \(-1.5\), \(-0.5\), \(0.5\), and \(1.5\) mg/L, so

$$ s_{e,i}^2 =\frac{(-1.5)^2+(-0.5)^2+(0.5)^2+(1.5)^2}{4-1} =\frac{2.25+0.25+0.25+2.25}{3} =\frac{5.00}{3} =1.67\text{ (mg/L)}^2. $$

The residual standard deviation is \(\sqrt{1.67}=1.29\) mg/L. The variance describes spread around the patient’s residual mean of \(0.500\) mg/L; it does not include that mean shift as part of the spread. To judge whether \(1.67\text{ (mg/L)}^2\) is unusually large, compare it with the appropriate model-based residual scale and account for the small number of visits. It should not be compared uncritically with a variance computed from many more visits.

Sign Runs in Measurement-Time Order

The sign-run summary reduces each nonzero residual to positive or negative and counts consecutive blocks in time order. A long run of positive signs is consistent with repeated measurements lying above the fitted trajectory over a stretch of visits; a long negative run has the analogous interpretation. Runs therefore highlight an ordered pattern that a mean or variance alone may not reveal. They do not measure the size of the residuals: a run of tiny positive residuals counts the same as a run of large positive residuals.

A simple reference for the number of runs comes from a random ordering of a fixed set of signs. Suppose \(n_+\) residuals are positive, \(n_-\) are negative, and \(N=n_++n_-\). Conditional on these counts, if every ordering is equally likely, the expected number of runs is

$$ E(R\mid n_+,n_-)=1+\frac{2n_+n_-}{N}. $$

This expectation is a benchmark, not a universal test of model adequacy. Its random-ordering assumption is not assured merely because a longitudinal model has been fitted. For a very small number of visits, the run count takes few possible values and is a coarse summary. Zero residuals have no sign; a consistent convention is to omit them when counting signs and report how many were omitted. If ties arise from rounding, inspect the unrounded residuals where possible.

Worked Example: Counting Runs

A third hypothetical patient has eight nonzero residuals, in time order, with signs \(+,+,+,-,-,+,-,-\). There are four positive and four negative residuals. The sequence has four runs: \(+++\), \(--\), \(+\), and \(--\). Under the random-ordering reference, the expected number is

$$ E(R\mid n_+=4,n_-=4) =1+\frac{2(4)(4)}{8} =1+4=5. $$

The observed count, \(R=4\), is one below that expectation. This sequence alone does not establish a systematic departure: it is a short record, and the reference is conditional on the observed sign counts. The initial three positive residuals may still be worth viewing against the measurement times and fitted trajectory, especially if their magnitudes are appreciable. A run count should prompt inspection, not serve as a stand-alone decision rule.

A Practical Diagnostic Sequence

Calculate summaries only after fixing the residual definition and ordering each patient’s observations by time. The following sequence keeps the three summaries distinct and makes comparisons more defensible.

1
Specify the residual.
Record whether it is conditional or marginal and whether it is raw or standardized. Keep the same definition when comparing patients.
2
Check the observation record.
Confirm visit times, residual signs, missing visits, and the number of measurements. Omit zero signs consistently for run counts and note the omission.
3
Read mean and variance together.
A nonzero mean indicates direction of average departure; a large variance indicates dispersion around that mean. Neither summary substitutes for the other.
4
Review the ordered residuals.
Use the run count as a compact sign-pattern summary, then inspect the actual time-ordered residuals and fitted values before drawing a conclusion.

Comparisons, Failure Modes, and Limits

A subject-level mean is more interpretable for persistent direction than a pooled residual mean, which can be near zero because positive and negative patient-level departures cancel. A subject-level variance adds information about within-patient spread, while the runs summary adds information about sign ordering. A residual plot retains magnitudes and timing, so it is usually the best companion display. These summaries do not replace the earlier material on marginal and conditional residuals, and they do not quantify residual autocorrelation; that is a separate diagnostic question.

SummaryWhat it highlightsImportant limitation
\(\bar e_i\)Average direction of departure for subject \(i\)Unstable with few visits; can be affected by trajectory estimation
\(s_{e,i}^2\)Spread around that subject’s residual meanNot comparable across unequal scales without suitable standardization
Run count \(R\)Clustering or alternation of residual signs in time orderIgnores residual magnitude and is coarse for short sequences
Time-ordered residual plotMagnitude, direction, and timing togetherRequires visual review and can be difficult to compare across many subjects

Several features of joint longitudinal and event data require particular caution. Patients have different numbers and timings of measurements, and observation may stop at an event or censoring time. A summary based on measurements available before that time does not describe unobserved later biomarker values. Conditional residuals also depend on estimated subject effects, which are informed by that patient’s measurements; this can make departures look smaller than they would under an independently specified prediction. Finally, an extreme subject-level summary can arise by chance when many patients are inspected. These summaries identify records for follow-up; they do not establish that an individual is an outlier, that a model component is wrong, or that a biomarker departure caused an event.

A common mistake is to declare that a patient has a mean-model failure because their residual mean is positive, or to call residual signs independent because the observed run count is near its reference expectation. The first ignores uncertainty and the fact that some nonzero means occur by chance; the second treats one coarse summary as proof of an assumption. Instead, consider visit count, residual scale, fitted trajectory, timing, and the pattern across patients. Then use suitable model diagnostics and substantive review to decide whether the fitted longitudinal component needs further investigation.

Key takeaway: Subject-level residual means, variances, and runs summarize different features of a patient’s repeated measurements. Interpret each relative to the chosen residual definition and the patient’s observation record; treat unusual values as diagnostic signals for review, not as automatic tests or conclusions.

Check Your Understanding

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

  1. A patient’s three residuals are \(0.3\), \(0.3\), and \(0.3\) mg/L. Calculate the residual mean and sample variance. What does each describe?
  2. Why should a raw residual variance based on one patient’s measurements not automatically be compared with a standardized residual variance for another patient?
  3. For the ordered signs \(+,-,+,-,+\), calculate the number of runs and the random-ordering expected run count.
  4. What does a subject-level conditional residual mean compare, and why might it differ from a marginal residual mean?

Solutions. (1) The mean is \((0.3+0.3+0.3)/3=0.300\) mg/L. Every residual equals the mean, so the sum of squared deviations is zero and \(s_{e,i}^2=0/(3-1)=0\text{ (mg/L)}^2\). The mean describes a consistent positive shift; the variance describes no observed spread around that shift. (2) The two variances are on different scales: standardization divides residuals by an estimated residual standard deviation. Compare like scales, and consider whether standardization is appropriate. (3) Every sign changes, so \(R=5\). Here \(n_+=3\), \(n_-=2\), and \(N=5\), giving \(E(R\mid n_+,n_-)=1+2(3)(2)/5=3.40\). The observed count is descriptive, not conclusive. (4) It compares measurements with the fitted trajectory conditional on the subject’s estimated random effects. A marginal prediction does not condition on those effects, so it represents a different reference trajectory and can produce different residuals.

Clinical Biostats