Documentation

18.33 RES, IWRES, WRES, and CWRES

Raw population residual is RES = DV − PRED; individual residual is IRES = DV − IPRED. IWRES divides IRES by the conditional residual SD \(\sqrt{V(\hat\eta)}\).

Residuals differ by prediction and whitening

WRES whitens (y-PRED) with the FO covariance based on \(G_0\Omega G_0^{\mathsf T}+V(0)\). CWRES whitens \(y-IPRED+G\hat\eta\) with the FOCE-I linearized covariance at the mode. Whitening accounts for within-subject covariance, not merely pointwise variance.

Likelihood records with nonzero F_FLAG have empty ordinary residuals. Excluded pre-dose zero-prediction records are marked rather than treated as model-fitting residuals. These population definitions must be aligned before reproducing NONMEM plots.

Residuals are diagnostics, not independent data. Their expected patterns rely on fitted parameters and approximations; smoothing is exploratory.

Practical interpretation

For one subject, build the linearized covariance and its Cholesky factor, then solve \(Lz=r\). The entries of \(z\) are whitened residuals; they are not produced by dividing each raw residual independently when covariance has off-diagonal terms. This small calculation explains why WRES/CWRES can differ from IWRES and why record order must be consistent.

Check residual implementation on a linear Gaussian case with an independently calculated covariance. Then add ETA-dependent error to distinguish WRES from CWRES. Unit tests should cover one observation, repeated observations and multiple ETAs.

Validate record alignment after sorting, exclusions and multiple endpoints; a correct formula applied to the wrong row order still produces false diagnostics.

Common mistakes

Do not call RES standardized, calculate CWRES as IRES/SD, or include censored records as observed numeric residuals. Avoid pooling different DVIDs/scales.

Checklist

  • Use exact formula and linearization point.
  • Confirm whitening matrix ordering.
  • Handle F_FLAG/exclusions.
  • Stratify by endpoint/design.
  • Compare residual distributions and trends.

Further reading

See docs/FITTING.md residual definitions and Chapter 21’s diagnostic plots.