Why Unequal Sampling Changes a Residual Summary
A pooled residual plot gives one point to every observation. When subjects contribute very different numbers of observations, a subject with many measurements contributes many points, while a subject with few measurements contributes only a few. The resulting display can be useful, but it does not automatically describe the typical subject equally well.
This distinction matters in nonlinear mixed-effects diagnostics because observation schedules may differ across individuals. A subject may have more observations because of a planned sampling schedule, missed visits in other subjects, or a design that samples some profiles more densely. The number of plotted points is therefore not necessarily the number of subjects represented equally.
The question is not whether observation weighting is always wrong or subject weighting is always right. The question is which population the summary is intended to describe: a randomly selected observation from the collected data, or a randomly selected subject whose observations are summarized first.
Residuals must be on a comparable scale for a pooled summary to be interpretable. For instance, the examples below use standardized residuals, which are dimensionless. If residuals are on a raw concentration scale, the summaries retain concentration units, and comparisons across settings with substantially different scales require care. The weighting calculations themselves do not require residuals to be independent. However, within-subject dependence means that a large number of observations should not be mistaken for an equally large number of independent subjects.
Two Ways to Average the Same Residuals
For subject \(i\), define the subject-specific mean residual as \(\bar r_i=(1/n_i)\sum_{j=1}^{n_i}r_{ij}\). The pooled mean gives each observation equal weight, whereas the equal-subject mean averages the \(m\) subject-specific means.
The pooled mean is a weighted average of subject means, with weights \(n_i/N\). A subject contributing 20% of all observations receives 20% of the pooled mean's weight. In the subject-weighted mean, every subject receives weight \(1/m\), regardless of their number of observations.
The same distinction applies to other summaries. For example, the observation-weighted mean absolute residual averages \(|r_{ij}|\) over all observations. The subject-weighted mean absolute residual first averages \(|r_{ij}|\) within each subject and then averages those subject-specific values. These answer different questions: average absolute deviation per observation versus average within-subject absolute deviation for a subject chosen equally from the sampled subjects.
Worked Example: Pooled and Subject-Weighted Mean Residuals
Suppose three hypothetical subjects have standardized residuals as follows: A has \(0.2,-0.2\); B has six residuals, all equal to \(1.0\); and C has \(-0.2,0.2\). Compare the pooled mean residual with the equal-subject mean residual.
There are \(N=2+6+2=10\) observations. Subject means are \(\bar r_A=(0.2-0.2)/2=0\), \(\bar r_B=6(1.0)/6=1.0\), and \(\bar r_C=(-0.2+0.2)/2=0\).
The observation-weighted mean is \( \bar r_{\mathrm{obs}}=[0.2-0.2+6(1.0)-0.2+0.2]/10=6/10=0.60. \)
The subject-weighted mean is \( \bar r_{\mathrm{subj}}=(0+1.0+0)/3=0.333. \)
Both calculations are correct for their respective weighting schemes. The pooled result gives subject B 60% of the total weight because B contributes 6 of the 10 observations. The subject-weighted result gives B one-third of the weight. Thus, the apparent positive average residual is stronger when the question is framed over the observations than when it is framed over these three subjects equally.
Absolute Residuals and Residual Spread
A mean residual can be close to zero because positive and negative residuals cancel, even when residuals are often far from zero. Absolute residuals or squared residuals can summarize magnitude without that cancellation. Their observation-weighted and subject-weighted versions still differ in exactly the same way: compute across all observations for the former, or compute within each subject and average across subjects for the latter.
For squared residuals, one useful subject-level measure is the root mean square (RMS) residual for each subject, \(\sqrt{(1/n_i)\sum_j r_{ij}^2}\). Averaging these subject-specific RMS values gives every subject equal weight. A different subject-weighted summary is the square root of the average subject-specific mean square. These are not generally equal, so the definition of the chosen summary should be reported.
Worked Example: Comparing Residual Magnitude Across Subjects
Use the following hypothetical standardized residuals: subject A has \(-1,1\); subject B has \(0,0,0,0\); and subject C has \(1,1\). Compare the pooled RMS residual with an equal-subject RMS based on averaging each subject's mean squared residual.
There are \(N=8\) observations. The pooled mean square is \( [(-1)^2+1^2+0^2+0^2+0^2+0^2+1^2+1^2]/8=4/8=0.50. \) The pooled RMS is therefore \(\sqrt{0.50}=0.7071\).
The subjects' mean squared residuals are 1 for A, 0 for B, and 1 for C. The equal-subject mean square is \((1+0+1)/3=0.6667\), giving an equal-subject RMS summary of \(\sqrt{0.6667}=0.8165\).
The pooled RMS is lower because subject B contributes four zero residuals, half of all observations. In the equal-subject calculation, B contributes one-third of the weight. Neither summary is universally preferable: the first describes the residual magnitude at a randomly selected collected observation; the second describes a root mean square based on equally weighted subjects' within-subject mean squares.
A pooled variance also reflects both variation within subjects and differences between subject means. This can be shown by writing each residual's deviation from the pooled mean as \(r_{ij}-\bar r_{\mathrm{obs}}=(r_{ij}-\bar r_i)+(\bar r_i-\bar r_{\mathrm{obs}})\). On squaring and summing, the cross-product for subject \(i\) is zero because \(\sum_j(r_{ij}-\bar r_i)=0\). Therefore:
The first term is within-subject variation. The second is variation among subject means, with each subject's contribution multiplied by its observation count. This identity explains why a pooled spread is not simply a typical within-subject spread: it also incorporates differences in subject means, and subjects with more observations have greater weight in that between-subject component.
Worked Example: Separating Within-Subject and Between-Subject Variation
For the residuals in the preceding example, the subject means are 0 for A, 0 for B, and 1 for C. The pooled mean is \((0+0+2)/8=0.25\). Verify the decomposition of the total squared deviation around the pooled mean.
The within-subject sum of squares is 2 for A, 0 for B, and 0 for C, for a total of 2. The between-subject component is \(2(0-0.25)^2+4(0-0.25)^2+2(1-0.25)^2=0.125+0.25+1.125=1.50.\)
The decomposition therefore gives \(2+1.50=3.50\). Directly, the total squared deviation from 0.25 is \(2(1.25^2)+4(0.25^2)+2(0.75^2)=3.125+0.25+1.125=4.50\)?
Rechecking the terms is essential: for subject A, the residuals are \(-1\) and \(1\), whose deviations from 0.25 are \(-1.25\) and \(0.75\), giving \(1.5625+0.5625=2.125\). Subject B contributes \(4(0.25^2)=0.25\), and subject C contributes \(2(0.75^2)=1.125\). The direct total is \(2.125+0.25+1.125=3.50\), matching the decomposition.
The initial expression \(2(1.25^2)\) incorrectly treats both residuals for A as having the same deviation from the pooled mean; the corrected calculation uses their actual values. The identity separates within-subject variation (2) from the weighted differences in subject means (1.50). The pooled variance using denominator \(N\) is \(3.50/8=0.4375\); a sample variance with denominator \(N-1\) would be a different summary.
Choose the Weighting to Match the Diagnostic Target
If the diagnostic question concerns a randomly selected recorded observation under the actual sampling scheme, observation weighting is natural. If it concerns the typical sampled subject, summarize within subjects first and weight subjects equally. If the intended target is a different population, neither unweighted approach necessarily matches it; a sampling or analysis design may require prespecified weights. These choices concern the summary's target, not a claim that one weighting reveals the model's truth.
Consider a third hypothetical data set: subject P contributes four residuals, all \(0.5\); subject Q contributes one residual, \(-1\); and subject R contributes one residual, \(-1\). The pooled mean is \([4(0.5)-1-1]/6=0\), whereas the equal-subject mean is \((0.5-1-1)/3=-0.5\). The pooled mean absolute residual is \([4(0.5)+1+1]/6=0.667\); the equal-subject mean absolute residual is \((0.5+1+1)/3=0.833\). Here dense sampling of P changes both the direction summary and the average magnitude relative to an equal-subject summary.
Neither calculation establishes that the model is biased or mis-specified. It identifies how the observed residual summary depends on sampling intensity. A useful diagnostic report can show a pooled display for observation-level patterns alongside subject-level summaries or per-subject displays. When numbers of observations vary greatly, report the distribution of \(n_i\) as context and check whether the main conclusion changes under subject weighting.
Diagnostics, Limitations, and Common Mistakes
Unequal sampling is a warning to inspect weighting, not by itself proof of a problem. Check whether a small number of subjects supply a large fraction of observations; whether high-count subjects have systematically different residual means or magnitudes; and whether the sampling schedule is related to covariates, response history, or study procedures relevant to interpretation. A pooled pattern dominated by a few subjects should be described as such rather than presented as if every subject contributed equally.
A common mistake is to say, “There are many residual points, so the pooled mean represents the typical subject precisely.” The correction is that the pooled mean targets an observation-weighted average, and multiple observations from one subject do not create additional subjects. Another mistake is to conclude that subject weighting is always superior. It is not: if the intended target is the recorded-observation distribution, equal-subject weighting changes that target.
Subject-level summaries also have limitations. A mean or RMS can hide time-ordered structure, changing residual spread, or a brief but important pattern within an individual. Subjects with only a few observations may have unstable subject-specific summaries. Consequently, an equal-subject aggregate should complement, not replace, inspection of individual profiles and residual patterns. Unequal sampling can also arise through missingness or design choices; weighting alone does not correct selection effects or establish why observations are missing.
Check Your Understanding
Answer each question by identifying the target and showing the relevant arithmetic where requested.
- Two subjects have residuals A: \(0,0\) and B: \(1,1,1,1\). Find the observation-weighted and equal-subject mean residuals.
- For the same data, calculate the observation-weighted and equal-subject mean absolute residuals.
- In one sentence, explain why six residuals from one subject do not represent six independent subjects.
- When might the observation-weighted summary be the appropriate target, and when might the subject-weighted summary be more relevant?
Solutions. (1) The pooled mean is \(4/6=0.667\). The subject means are 0 and 1, so their equal-subject mean is \((0+1)/2=0.50\). (2) The pooled mean absolute residual is \(4/6=0.667\); the subject means of absolute residual are 0 and 1, whose equal-subject average is 0.50. (3) Residuals from one subject share the same individual and may be correlated, so they do not supply the same independent-subject information as observations from six different subjects. (4) Observation weighting matches a target defined over recorded observations under the sampling scheme; subject weighting better matches a target defined over subjects summarized equally. Always identify the target before choosing the summary.