Why Compare Residuals Across Groups?
A model can describe the overall concentration data reasonably well while systematically underpredicting concentrations in one treatment arm or showing more variable residuals at one site. Comparing residuals across categorical groups helps reveal these patterns. Relevant groupings may include treatment arm, study site, formulation, or a clinically meaningful patient category such as renal-function class.
The question is not simply whether one group has more residuals than another. A larger group naturally contributes more plotted points and may have a more stable summary. The diagnostic question is whether residuals have different centers or spreads across groups, in a way that suggests a systematic model discrepancy or a difference in variability.
The earlier material on population predictions, individual predictions, and residuals distinguishes residual types. That distinction matters here: raw residuals may be on a concentration scale with scale-dependent variability, whereas a standardized weighted residual is intended to account for modeled residual variability. Conditional weighted residuals are approximately standard normal when their underlying model and approximation conditions are adequate. Thus, a center near zero and a spread near one are useful reference points for such residuals, but are not universal targets for every residual type.
Groupwise Summaries and Their Interpretation
For each group, calculate the mean and sample standard deviation. The mean indicates whether residuals tend to lie above or below zero; the standard deviation indicates how dispersed they are around their own group mean. Always report the group sample size alongside these summaries.
A positive \(\bar{r}_g\) means residuals in group \(g\) tend to be positive under the residual sign convention being used; a negative mean indicates the opposite. Check that convention before describing the pattern as underprediction or overprediction. If residuals are observed minus predicted, a positive residual generally indicates underprediction. A larger \(s_g\) indicates more within-group dispersion, but may reflect a few extreme values, a different mix of sampling times or predictions, or a genuine difference in residual variability.
Group means do not generally have equal influence on the overall mean. If the same residuals are pooled, the overall mean is a sample-size-weighted average of the group means:
This identity follows by writing the sum of all residuals as the sum of the residuals within each group: \(\sum_g\sum_i r_{ig}=\sum_g n_g\bar{r}_g\). Dividing by the total number of residuals gives the formula. Consequently, a large group can dominate a pooled summary, and a pooled mean near zero can conceal offsetting positive and negative group means.
Worked Example: Comparing Treatment-Arm Centers and Spreads
Suppose a hypothetical model produces conditional weighted residuals for two treatment arms. Arm A has \(n_A=8\) residuals: \(-2,-1,-1,0,0,1,1,2\). Arm B has \(n_B=12\) residuals: \(-1,-1,0,0,0,0,1,1,1,1,2,2\). Calculate each group’s mean and sample standard deviation, then the pooled mean.
For Arm A, the sum is \(-2-1-1+0+0+1+1+2=0\), so \(\bar{r}_A=0/8=0\). The sum of squared residuals is \(4+1+1+0+0+1+1+4=12\). Since its mean is zero, the sum of squared deviations from the mean is also 12. Therefore,
For Arm B, the sum is \((-1)+(-1)+0+0+0+0+1+1+1+1+2+2=6\), so \(\bar{r}_B=6/12=0.5\). Its sum of squares is \(1+1+0+0+0+0+1+1+1+1+4+4=14\). The sum of squared deviations from its mean is \(\sum_i r_{iB}^2-n_B\bar{r}_B^2=14-12(0.5)^2=14-3=11\). Thus,
Arm B has a positive mean residual of 0.5, while Arm A is centered at zero. The within-arm spreads are 1.000 and 1.309, respectively. The pooled mean is \((8(0)+12(0.5))/(8+12)=6/20=0.300\). Because Arm B has more observations, its mean contributes more to the pooled mean. If these are conditional weighted residuals, the positive mean in Arm B is a diagnostic signal to investigate, not by itself proof that the model is misspecified. The group sizes and the data structure should also be considered.
Plot Before Concluding
A useful comparison combines a plot with a compact table of group sample sizes, means, and standard deviations. A dot plot or box plot by group shows whether a summary is driven by a few values or reflects a broad shift. Add a horizontal zero reference for residuals expected to be centered at zero. If residuals are intended to have unit spread, a spread reference can also aid interpretation, but it should not be mistaken for a strict acceptance boundary.
Show the number of observations in each group on the plot or in its labels. Groups with different \(n_g\) contribute different numbers of points, so point density alone can mislead. A group with more points can look visually dominant even when its residual distribution is similar to that of a smaller group. Conversely, a small group may have a striking mean or spread simply because a few residuals have substantial influence. Displaying individual points where practical makes this vulnerability visible.
The grouping variable also needs a clear definition. For example, a patient belongs to one treatment arm, while a site may contain many patients. If residuals are repeated within patients, the observation count is not the patient count. Report both when relevant. The summaries remain descriptive, but repeated observations from one patient should not be treated as independent evidence when making inferential claims about groups.
Worked Example: Identifying a Site-Level Offset
Consider hypothetical conditional weighted residuals from two sites. Site 1 has \(-1,0,0,1\), and Site 2 has \(0,1,1,2\). Both sites have four residuals. Calculate their centers and spreads.
For Site 1, the sum is zero, so \(\bar{r}_1=0/4=0\). Its sum of squares is \(1+0+0+1=2\), giving \(s_1=\sqrt{2/(4-1)}=\sqrt{2/3}=0.8165\).
For Site 2, the sum is \(0+1+1+2=4\), so \(\bar{r}_2=4/4=1\). The sum of squares is \(0+1+1+4=6\). The sum of squared deviations from its mean is \(6-4(1)^2=2\), so \(s_2=\sqrt{2/3}=0.8165\).
The groups have the same sample size and the same within-group spread, but Site 2 is shifted upward by one residual unit. If positive residuals indicate observed concentrations above predictions, this pattern is consistent with underprediction at Site 2. It could also arise from differences in the patients, dose histories, sampling schedules, or data handling at the two sites. The plot identifies a pattern to investigate; it does not establish its cause.
Worked Example: Separating Centering From Spread
Suppose two hypothetical patient categories have conditional weighted residuals. Category C has \(-2,0,0,2\), and Category D has \(-1,-1,1,1\). Compare their centers and standard deviations.
Both sums are zero, so \(\bar{r}_C=\bar{r}_D=0\). For C, the sum of squares is \(4+0+0+4=8\), giving \(s_C=\sqrt{8/(4-1)}=\sqrt{8/3}=1.633\). For D, it is \(1+1+1+1=4\), giving \(s_D=\sqrt{4/3}=1.155\).
The group centers agree, but Category C has greater residual spread. That pattern differs from a consistent shift in one group’s mean: here residuals are not systematically positive or negative in either category, but their variability differs. Check whether this contrast persists across individual observations and relevant design features. With only four observations per category, these summaries are highly sensitive to the particular residuals observed.
Assumptions, Alternatives, and Failure Modes
Groupwise summaries are straightforward to calculate, but sound interpretation requires several checks. Use the same residual definition and scale for every group being compared. Confirm that group membership is recorded consistently, and consider whether groups differ in design features such as sampling times or concentration ranges. If residuals are not standardized, their expected spread may naturally vary across those features; an apparent group difference is then not automatically evidence of a group-specific model problem.
No independence assumption is needed merely to calculate a group mean or sample standard deviation. However, repeated residuals from one participant are related by the study structure, so treating them as independent for uncertainty estimates or formal tests can overstate the amount of information. This tutorial uses group summaries as diagnostics, not as a substitute for an analysis that accounts for the data structure.
There are several useful comparisons, each with a different role:
- Groupwise summaries are concise and easy to compare, but can conceal outliers, multimodality, or different distributions with similar means and standard deviations.
- Plots of individual residuals by group reveal distribution shape and influential points, but become crowded with large samples and can exaggerate the prominence of groups with more observations.
- A pooled summary describes the combined data, but can hide opposing group patterns and gives larger groups more weight.
- Residuals across a continuous covariate are more appropriate when the suspected pattern changes gradually with a numerical variable rather than differing among defined categories.
A common mistake is to conclude that the largest group has the greatest model bias because it has the most points above zero. Point count is not a measure of bias: compare the group’s residual center and distribution, while displaying \(n_g\) to show how much information supports that comparison. Another mistake is to infer that equal group means imply equal fit. As the spread example shows, two groups can both be centered at zero while having different variability.
Groupwise diagnostics have limits. A categorical split can obscure important variation within a group, and very small groups provide unstable summaries. Differences can also reflect chance, the mix of observations, or data-quality issues rather than model structure. Treat a visible pattern as a prompt to inspect the relevant records, design features, and model assumptions—not as an automatic reason to add a group effect.
Check Your Understanding
Try each problem, then compare your reasoning with the worked solutions below.
- A group has residuals \(-1,0,1\). Find its mean and sample standard deviation.
- Two groups have residual means of \(0.2\) and \(0.8\). The second group has four times as many observations. Why is the overall mean closer to the second group’s mean, and what is needed to calculate it exactly?
- Two patient categories have residual means near zero, but one has a much larger sample standard deviation. Does that indicate a difference in centering, spread, or both?
- A site has many more plotted residuals than another site, and consequently more points above zero. Is this alone evidence of greater site bias? State what to examine instead.
Solutions. (1) The mean is \((-1+0+1)/3=0\). The sum of squared deviations is \(1+0+1=2\), so the sample standard deviation is \(\sqrt{2/(3-1)}=1\). (2) The pooled mean weights each group mean by its sample size, so the larger group has greater influence. The exact overall mean requires both group sizes: \((n_1(0.2)+n_2(0.8))/(n_1+n_2)\). (3) This indicates a difference in spread, not necessarily in centering; both centers remain near zero. Inspect the observations and group sizes before judging how stable the spread contrast is. (4) No. The larger number of points may simply reflect a larger sample. Compare groupwise centers and spreads, inspect the individual residual distributions, and consider the number of patients as well as the number of observations if measurements repeat within patients.