Tutorials › Stochastic Differential Equations in Pharmacokinetics › Calibration, Model Adequacy, and Model Comparison

Simulation-Based Calibration and Model Comparison · Tutorial 89 of 100

Calibration, Model Adequacy, and Model Comparison

Distinguish whether an inference algorithm works as intended, whether an SDE describes the observed data adequately, and which candidate predicts better.

Advanced 10 min read

What You'll Learn

  • Define algorithm calibration, model adequacy, and predictive comparison as separate questions.
  • Derive the uniform-rank result behind simulation-based calibration.
  • Use posterior predictive checks to assess data features relevant to an SDE.
  • Compare candidates using held-out log predictive density on a shared target.
  • Recognize what a successful diagnostic does not establish.

Three Questions That Must Not Be Confused

A residual plot, a simulation diagnostic, and a predictive score may all be called “model checks,” but they answer different questions. In an SDE analysis, first ask whether the inference algorithm returns the intended distribution, then whether the fitted generative model can reproduce important features of the data, and finally whether one candidate gives better predictions than another. Passing one check does not establish the others.

For example, an algorithm can accurately sample from the posterior distribution of a misspecified SDE. Its computation is then calibrated to the assumed model, even though that model may fail to describe the observed concentration trajectories. Conversely, an SDE may be scientifically adequate while a coding error or poorly mixing sampler produces unreliable posterior estimates. Predictive comparison is relative: one candidate may forecast better than another even though both have important shortcomings.

Definition: Algorithm calibration asks whether an inferential procedure, under repeated data generation from its assumed model, produces inferential output with the properties required of the exact target distribution. Model adequacy asks whether the model can reproduce data features that matter for its intended use. Predictive model comparison evaluates the predictive distributions of competing candidates on a specified prediction target, preferably data not used to fit them.

Simulation-Based Calibration of an Inference Algorithm

Simulation-based calibration (SBC) checks computation under a known generative model. Its basic procedure is: draw parameters from the prior, simulate data conditional on those parameters, run the inference algorithm, and compare the generating parameter with draws from the resulting posterior. This is a check of the algorithm relative to the specified prior and likelihood; it is not a test that the specified SDE is a realistic account of a clinical population.

Here is the basic rank result. Suppose the parameter is scalar and continuous, the prior is proper, the data are generated from the prior predictive distribution, and the algorithm returns independent exact draws from the posterior. Conditional on the simulated data, the generating parameter and the posterior draws have the same distribution. Their rank is therefore uniform, provided ties have probability zero.

Theorem: Let \(\theta_0\) be drawn from the prior, let \(Y\) be drawn from the model conditional on \(\theta_0\), and let \(\theta_1,\ldots,\theta_M\) be independent draws from the exact posterior distribution of \(\theta\) given \(Y\). If this posterior is continuous, then the rank \(R=\sum_{m=1}^{M} I(\theta_m<\theta_0)\) is uniform on \(\{0,1,\ldots,M\}\).

Proof. For any fixed data value \(Y=y\), Bayes’ rule says that the conditional distribution of \(\theta_0\) given \(Y=y\) is the posterior. The draws \(\theta_1,\ldots,\theta_M\) are also independent draws from that posterior. Thus, conditional on \(Y=y\), the \(M+1\) values are independent and identically distributed. With a continuous distribution, they have no ties with probability one. By exchangeability, each of the \(M+1\) values is equally likely to occupy any specified rank. In particular, \(\theta_0\)'s rank is each of \(0,\ldots,M\) with probability \(1/(M+1)\). This conditional distribution does not depend on \(y\), so the same uniform result holds after averaging over \(Y\). \(\square\)

Worked Example: An SBC Rank Under a Normal Model

Let the prior be \(\theta\sim N(0,1)\), and let the observation satisfy \(Y\mid\theta\sim N(\theta,1)\). For one simulated data set, suppose the generated value is \(\theta_0=1.4\) and the observed value is \(y=2\). The posterior is \(N(1,0.5)\): completing the square in the prior and likelihood gives posterior precision \(1+1=2\), variance \(1/2\), and mean \(2/2=1\).

Suppose four posterior draws from the algorithm are \(0.2,\ 0.8,\ 1.1,\ 1.7\). Three are less than \(1.4\), so the rank is \(R=3\), one of the five possible ranks \(0,1,2,3,4\). This single rank does not test uniformity. Repeating the entire prior-predictive simulation and inference procedure produces a collection of ranks; under the theorem, their frequencies should be compatible with a uniform distribution, apart from ordinary simulation variation.

A systematic excess of ranks near zero or \(M\) can indicate biased or insufficiently mixed posterior draws, a coding error, or a mismatch between the implemented likelihood and the simulator. It does not by itself identify which cause is responsible. Also, a uniform-looking histogram is not proof of correctness: the test may have limited power, especially for errors affecting only a small region of parameter space.

Model Adequacy: Can the SDE Reproduce Relevant Data?

After computation is checked, assess whether the fitted model can reproduce features of the observations that matter scientifically. A posterior predictive distribution for a replicated data set \(Y^{\mathrm{rep}}\), conditional on observed data \(y\), is defined by first drawing \(\theta\) from the posterior given \(y\), then drawing \(Y^{\mathrm{rep}}\) from the model conditional on \(\theta\). In a pharmacokinetic SDE, this procedure may include simulating latent paths and the observation process. The replicated data must be generated using the same dosing, sampling times, and observation model as the data being checked.

A useful check chooses a discrepancy or summary \(T(Y)\) before interpreting the results. Examples include the number of unexpectedly large one-step innovations, the maximum concentration, a late-time concentration summary, or the variability among subjects. Compare \(T(y)\) with its distribution across replicated data sets. The choice should reflect the intended scientific use: reproducing the mean concentration profile alone may be insufficient if peak exposure or between-subject variability is central.

Worked Example: Checking an Extreme One-Step Innovation

Suppose a fitted SDE and observation model imply that, under adequate specification, a particular standardized one-step innovation \(Z\) is approximately \(N(0,1)\). The observed innovation is \(z=2.4\). Its two-sided tail probability under that reference distribution is \(P(|Z|\geq 2.4)=2[1-\Phi(2.4)]\). Using \(\Phi(2.4)\approx0.9918\), this is approximately \(2(0.0082)=0.0164\).

This is a signal worth investigating, not a verdict that the model is wrong. If there are 12 innovations and the check is selected in advance, the probability that at least one exceeds 2.4 in absolute value, under independent standard-normal innovations, is \(1-(1-0.0164)^{12}\approx 0.180\). The calculation uses independence; if the innovations are serially dependent, this reference probability is not valid. The observation might reflect a poorly described transient, an unusual measurement, or chance. Examine the time and subject context, and use replicated trajectories to check whether the model reproduces the relevant pattern. The earlier material on SDE residual diagnostics concerns constructing and interpreting innovation sequences; this check concerns what their behavior implies for model adequacy.

Posterior predictive checks are descriptive checks of compatibility, not automatic hypothesis tests with a universal pass/fail threshold. Because the observed data inform the posterior used to generate the replications, posterior predictive tail areas generally should not be interpreted as uniformly distributed \(p\)-values under a correct model. A useful report states the discrepancy, how it was selected, the observed value, and the range or distribution from replicated data.

Predictive Model Comparison

Model adequacy asks whether a candidate can reproduce relevant data. Predictive comparison asks which of two or more candidates predicts a defined target better. To avoid rewarding a model for fitting the same observations on which it was judged, evaluate predictions on held-out observations or use a justified cross-validation procedure. Candidates must be evaluated on the same cases, outcomes, and conditioning information. For a held-out observation \(y_i\), a common score is the log predictive density \(\log q(y_i)\), where \(q\) is the candidate’s predictive density given the training data and the available predictors.

Theorem: If the true predictive density is \(p\) and a candidate predictive density is \(q\), and both are densities with \(p\) absolutely continuous with respect to \(q\) and the relevant expectations are finite, then \(E_p[\log p(Y)]-E_p[\log q(Y)]=D_{\mathrm{KL}}(p\|q)\geq0\). Thus expected log score is maximized by the true predictive distribution.

Proof. By definition, \(D_{\mathrm{KL}}(p\|q)=\int p(y)\log[p(y)/q(y)]\,dy\), which equals the difference of expectations in the statement. To show nonnegativity, use \(\log x\leq x-1\) for \(x>0\), with \(x=q(y)/p(y)\) wherever \(p(y)>0\). Then \(\int p(y)\log[q(y)/p(y)]\,dy\leq\int p(y)[q(y)/p(y)-1]\,dy\leq 0\), because \(\int q(y)\,dy=1\) and \(\int_{\{p>0\}}q(y)\,dy\leq1\). Negating gives \(D_{\mathrm{KL}}(p\|q)\geq0\). Equality holds when \(p=q\) almost everywhere. \(\square\)

Worked Example: Comparing Two Predictive Densities

For one held-out concentration, let the observed value on a chosen transformed scale be \(y=1.5\). Candidate A predicts \(Y\sim N(0,1)\), and candidate B predicts \(Y\sim N(1,0.5)\), where the second argument denotes variance. The normal log density is \(\log q(y)=-\tfrac12\log(2\pi v)-\tfrac{(y-\mu)^2}{2v}\).

For A, \(\mu=0\) and \(v=1\), so \(\log q_A(1.5)=-\tfrac12\log(2\pi)-1.5^2/2\approx-0.9189-1.125=-2.0439\). For B, \(\mu=1\) and \(v=0.5\), so \(\log q_B(1.5)=-\tfrac12\log(\pi)-0.5^2/(1)\approx-0.5724-0.25=-0.8224\). Candidate B assigns this observation a higher log predictive density by about \(1.2215\). This is evidence in favor of B for this observation only; a comparison across a sufficiently large, representative set of held-out observations is more informative. A single observation cannot establish overall predictive superiority or model adequacy.

Diagnostics, Alternatives, and Limits

The three questions call for different diagnostics. For algorithm calibration, inspect repeated SBC ranks and also monitor sampler-specific diagnostics such as effective sample sizes and convergence across chains. For model adequacy, examine posterior predictive distributions of prespecified summaries and relevant residual patterns. For predictive comparison, report paired differences in held-out scores and their uncertainty; do not compare scores computed on different targets or different held-out cases.

Common alternatives answer related but distinct questions. Information criteria and likelihood-based comparisons can be useful when their assumptions and target are appropriate, but they are not substitutes for checking predictions on the intended task. In particular, a criterion aimed at in-sample fit or an approximation to predictive performance need not reveal a failure in a clinically important tail or dose-time region.

Common mistake: “The SBC ranks look uniform, so the SDE is adequate.” This conclusion is invalid. Uniform ranks support the claim that the algorithm behaves correctly on simulations from the assumed model and prior; they do not test whether that model resembles observed clinical data. The correction is to report the algorithm check separately, then examine model adequacy using data-relevant replicated summaries, and compare predictions on a clearly specified target.

A second limitation is scope. SBC conclusions depend on the prior-predictive simulations covering the parameter regions of interest; a narrow or unrealistic prior may fail to expose errors elsewhere. Predictive scores depend on the test population and prediction horizon: better prediction at observed sampling times does not guarantee reliable extrapolation to a new dose or schedule. Adequacy is therefore purpose-dependent, and comparison is relative rather than an assertion that the winning candidate is true.

Key takeaway: Keep three claims separate: “the algorithm samples its target,” “the model can reproduce features relevant to the data and use,” and “this candidate predicts better on this evaluation target.” Each requires its own evidence.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In SBC, why must the generating parameter and posterior draws be exchangeable for the uniform-rank result?
  2. A rank histogram is approximately uniform, but replicated data systematically underpredict peak concentrations. What has and has not been established?
  3. For a held-out observation, candidate A has log predictive density \(-1.7\) and candidate B has \(-2.1\). Which scores better on this observation, and what additional information is needed?
  4. Why is a posterior predictive tail area not automatically a uniformly calibrated hypothesis-test \(p\)-value?

Solutions. (1) Conditional on the simulated data, the generating parameter has the posterior distribution, just like each exact posterior draw. Independent identically distributed continuous values have equally likely ranks. (2) The computation is compatible with the SBC check under the tested prior and simulator, but the model has evidence of an adequacy problem for peak concentrations; the rank result does not repair that failure. (3) A scores better because \(-1.7>-2.1\). The scores should be compared over the same held-out target and a representative collection of cases, with uncertainty in the aggregate difference considered. (4) The observed data are used to form the posterior that generates the replicated data, so the observed discrepancy and replications are not generally distributed as in a classical test with a fixed null distribution. The tail area is a model-checking summary, not automatically a uniform \(p\)-value.

Clinical Biostats