Chapter 21 — Diagnostics and goodness of fit
A successful minimization answers a numerical question: the optimizer found a parameter vector satisfying its termination rule. Diagnostic review asks the broader pharmacometric question: does the fitted model describe the observed data adequately for its intended use? Chapter 21 teaches that review from first principles.
The diagnostic behavior and option reference were reviewed against the current nlmx 4.8.0 source. The chapter uses the preserved, checksum-verified nlmx 4.7.0 Chapter 20 oral fit as a running evidence bundle; its predictions.csv, parameter table, PHI output, summaries, HTML report, and eight publication plots provide real output. Conceptual figures then show failure patterns that the deliberately well-behaved example does not contain. The version distinction is explicit so frozen evidence is never presented as output from a binary that did not create it.
The central rule is simple: no single plot validates a model. Population predictions, individual predictions, residuals, random effects, shrinkage, uncertainty, boundary behavior, event interpretation, stratification, and predictive checks answer different questions. They must be read together and in a deliberate order.
How the chapter is organized
The first pages define the diagnostic population, files, plots, and prediction/residual quantities. The middle pages explain each standard plot and the limits of LOESS, ETA distributions, shrinkage, identifiability, transformations, filtering, stratification, DVID, F_FLAG, and predose exclusions. The final pages cover publication output, a fully annotated worked example, common misspecification patterns, decision rules, and a review/reporting checklist.
The chapter contains 30 numbered pages plus this overview and a complete diagnostic-option index. Chapter 27 later adds simulation-based VPC, pcVPC, and numerical predictive checks; those are complementary, not replacements for the fit diagnostics described here.
Evidence boundary
Good-looking diagnostics are necessary but cannot prove that an unobserved extrapolation is correct, that parameters are identifiable, or that a selected model is causal. Diagnostics are conditional on the data, likelihood, approximation, and model implementation. Preserve those conditions whenever a figure is circulated.