Tutorials › Stochastic Differential Equations in Pharmacokinetics › End-to-End Validation and Comparison Workshop

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

End-to-End Validation and Comparison Workshop

Learn to connect simulation, calibration checks, model comparison, and algorithm diagnostics into a defensible end-to-end PK SDE analysis.

Advanced 13 min read

What You'll Learn

  • Design a simulation study that preserves the PK sampling and dosing structure.
  • Interpret simulation-based calibration ranks and coverage without confusing either with model adequacy.
  • Compare candidate models using predictions for the same held-out observations.
  • Separate parameter uncertainty from future-observation uncertainty.
  • Report numerical reliability, predictive uncertainty, and limitations transparently.

Why Validate the Whole Analysis?

A PK SDE analysis is a chain of dependent choices: a stochastic model generates latent concentration paths, an observation model connects those paths to measurements, and a computational method approximates the posterior and predictive distributions. A plausible parameter estimate alone does not establish that the chain works. The fitted model may be misspecified, the posterior computation may be unreliable, or predictions may be much less certain than a point estimate suggests.

An end-to-end validation study makes these issues visible by generating data under controlled conditions and then repeating the intended analysis. It combines the earlier material on calibration and model comparison with residual diagnostics and predictive distributions. The goal is not to certify a model once and for all. It is to find out how the proposed analysis behaves under specified conditions, and to state what the evidence does and does not support.

A Simulation and Evaluation Plan

Begin by specifying the data-generating process, including the dose history, observation times, subject variability, stochastic path variation, and measurement error. Generate complete synthetic trials from known parameter values or from a declared parameter distribution. Then fit each candidate model using the same observation data and a documented computational procedure. Reserve observations or trials for predictive evaluation when the comparison requires a genuine out-of-sample check.

Definition: End-to-end validation evaluates a complete analysis pipeline by generating data under an explicit simulation design and applying the planned fitting, diagnostic, comparison, and prediction procedures to those data. Its conclusions are conditional on the scenarios simulated; it cannot establish performance under every possible data-generating process.

A useful design varies features that may challenge the analysis: sample size, observation timing, dose schedule, between-subject variability, diffusion magnitude, measurement error, and proximity to parameter boundaries. Include both scenarios in which a candidate is correctly specified and scenarios in which it is not. This separates the question “does the computation recover the intended answer under its own assumptions?” from “does the model describe data generated by a different process?”

For a transparent illustration, suppose the latent concentration follows the geometric Brownian PK model

$$ dC_t=-kC_t\,dt+\sigma C_t\,dW_t,\qquad C_0>0, $$

where \(k>0\), \(\sigma\geq 0\), and \(W_t\) is standard Brownian motion. Measurements may be made on the log scale as \(Y_j=\log C_{t_j}+\epsilon_j\), with independent \(\epsilon_j\sim N(0,\tau^2)\). The model keeps concentration positive, and \(\sigma=0\) gives the deterministic exponential-disposition case. These assumptions define a simulation example, not a claim that this model is appropriate for every PK setting.

Worked Example: Simulating One Concentration Trajectory

Take \(C_0=10\), \(k=0.30\), \(\sigma=0.20\), and time steps of one hour. Choose Brownian increments \(0.50,-1.00,0.25\). For a step of length one, the exact log-concentration increment is

$$ \Delta\log C=-(k+\sigma^2/2)+\sigma\Delta W =-(0.30+0.20^2/2)+0.20\Delta W =-0.32+0.20\Delta W. $$

The three increments are therefore \(-0.32+0.10=-0.22\), \(-0.32-0.20=-0.52\), and \(-0.32+0.05=-0.27\). Starting with \(\log C_0=\log(10)=2.3026\), the log concentrations at hours 1, 2, and 3 are \(2.0826\), \(1.5626\), and \(1.2926\). Exponentiating gives approximately \(8.03\), \(4.77\), and \(3.64\) concentration units. If measurement errors on the log scale are \(0.03,-0.04,0.02\), the observed log concentrations are \(2.1126,1.5226,1.3126\). Their corresponding concentrations are approximately \(8.27,4.58,3.72\). The observed values differ from the latent path because of measurement error; they should not be substituted for the simulated latent values when checking path-generation code.

Posterior Calibration and Coverage

Simulation-based calibration (SBC) checks whether posterior computation behaves as expected when the model and prior used for fitting are also the data-generating model. In each replicate, draw parameters from the prior, simulate data conditional on them, and draw from the posterior conditional on those data. Compare the generating value with the posterior draws. This assesses computation under the specified model; it is not, by itself, evidence that the model adequately describes real data.

Definition: For a scalar parameter \(\theta\), an SBC rank is the number of posterior draws below the generating value, with a specified random tie-breaking rule when values are tied. With \(S\) posterior draws, the rank is one of \(0,1,\ldots,S\). Under exact posterior sampling and the prior-predictive simulation design, these ranks are uniformly distributed across repeated replicates.

The reason for the uniform ranks is exchangeability. In one replicate, first draw \(\theta\) from its prior and data \(Y\) from the model conditional on \(\theta\). Given \(Y\), draw \(S\) independent values from the exact posterior. The generating \(\theta\), conditional on \(Y\), has that same posterior distribution as each of the \(S\) draws. Thus the \(S+1\) values are exchangeable conditional on \(Y\). For a continuous parameter, ties have probability zero, and each value is equally likely to occupy any of the \(S+1\) ordered positions. The generating value’s rank is therefore uniform. With discrete parameters or ties, randomizing the order within tied values gives the corresponding uniform-rank result. This argument requires proper prior-predictive simulation, the same model for generation and fitting, and exact independent posterior draws; approximate, dependent computation can distort ranks.

Worked Example: Calculating an SBC Rank

Suppose one simulation draws a true value \(\theta=0.40\). Nine posterior draws, sorted from smallest to largest, are \(0.12,0.25,0.31,0.37,0.44,0.49,0.55,0.61,0.72\). Four draws are below the generating value, so its rank is \(R=4\), out of the ten possible ranks \(0,\ldots,9\). The scaled rank is \(R/(S+1)=4/10=0.40\). One rank is not a calibration diagnosis. Across many independent simulation replicates, an excess of low ranks can indicate posterior draws that tend to be too high relative to the generating values; an excess of high ranks can indicate the reverse. A U-shaped pattern can indicate posterior distributions that are too concentrated, while a central concentration can indicate posteriors that are too diffuse. These patterns are clues to investigate, not unique diagnoses.

Coverage complements ranks. For example, a nominal 90% posterior interval should contain the generating parameter in about 90% of repeated prior-predictive simulations if the model and posterior computation are correct. In a finite simulation study, observed coverage has sampling variability, so report the number of replicates and uncertainty around the estimated coverage. Also check joint calibration when dependence among parameters matters: marginally calibrated parameters can still have a miscalibrated joint posterior.

Model Comparison and Predictive Uncertainty

Compare candidates using predictions evaluated on the same held-out observations or trials. A log predictive density score rewards assigning high probability to outcomes that were not used to fit the model. For held-out observations \(y_1,\ldots,y_m\), one possible summary is the sum of their log predictive densities. Scores are comparable only when candidates predict the same outcomes on the same scale and with the same conditioning information. If a model has a higher score, that is evidence for better prediction on this evaluation set; it is not proof that the model is true.

Worked Example: Comparing Held-Out Predictive Scores

Suppose three candidates are evaluated on the same three held-out observations. Their observation-wise log predictive densities are: deterministic model \(M_0\), \(-1.8,-2.1,-1.6\); diffusion model \(M_1\), \(-1.2,-1.4,-1.5\); and mixed-effects model \(M_2\), \(-1.0,-1.8,-1.9\). The sums are \(-1.8-2.1-1.6=-5.5\), \(-1.2-1.4-1.5=-4.1\), and \(-1.0-1.8-1.9=-4.7\). Thus \(M_1\) has the largest total score, by \(1.4\) relative to \(M_0\) and \(0.6\) relative to \(M_2\). With only three observations, these differences are descriptive and potentially unstable. A careful study repeats the comparison across trials or folds and reports variation in paired score differences rather than treating this small ranking as decisive.

A prediction averages over posterior uncertainty in parameters and latent states, and may also include new measurement error. These sources should be distinguished in reporting. For a predictive variable \(Y\) and parameter \(\theta\), with finite second moments, the law of total variance is

$$ \operatorname{Var}(Y\mid y) =E[\operatorname{Var}(Y\mid\theta,y)\mid y] +\operatorname{Var}(E[Y\mid\theta,y]\mid y). $$

To verify it, write \(m(\theta)=E[Y\mid\theta,y]\). Add and subtract \(m(\theta)\) inside the squared deviation from the overall mean \(\mu=E[Y\mid y]\). After expanding, the cross term has conditional expectation zero because \(E[Y-m(\theta)\mid\theta,y]=0\). The remaining terms are \(E[\operatorname{Var}(Y\mid\theta,y)\mid y]\) and \(E[(m(\theta)-\mu)^2\mid y]\), which are the two terms displayed. The first represents average conditional predictive variation; the second represents variation in conditional means across posterior parameter values.

Worked Example: Decomposing Predictive Variance

Suppose the posterior has two equally likely parameter states. In state 1, the predictive mean is 4 and the conditional predictive variance is 1. In state 2, the mean is 6 and the conditional variance is also 1. The overall predictive mean is \((4+6)/2=5\). The expected conditional variance is \((1+1)/2=1\), and the variance of the two conditional means is \(((4-5)^2+(6-5)^2)/2=1\). The total predictive variance is therefore \(1+1=2\), with predictive standard deviation \(\sqrt{2}\approx1.41\). Reporting only the conditional standard deviation of 1 would omit the uncertainty about which parameter state applies.

Computational Reliability and Failure Modes

A validation report should make it possible to distinguish model behavior from algorithm behavior. For posterior simulation, inspect trace plots, effective sample sizes, between-chain agreement such as \(\hat R\), and any sampler-specific warnings. Compare independent runs and, where feasible, known-parameter simulation results. For discretized SDE likelihoods or path simulations, assess sensitivity to the time step or approximation method. A predictive score can be misleading if it reflects numerical error rather than model fit.

1
Check the generator.
Test simulated trajectories against known special cases, such as \(\sigma=0\), and verify dose timing, units, positivity constraints, and observation-error generation.
2
Check computation.
Run multiple chains, examine mixing and effective sample sizes, investigate warnings, and repeat fits with tighter numerical settings when approximation error is possible.
3
Check calibration and adequacy separately.
Use SBC and coverage under the model’s own simulation design to assess inference; use residual and predictive checks under relevant scenarios to assess whether the model captures the data features of interest.
4
Compare and communicate.
Evaluate candidates on common held-out outcomes, summarize score variability, and report predictive intervals alongside the assumptions and limitations that produced them.

A frequent mistake is to read a uniform SBC rank histogram as proof that the model is adequate. Uniformity is expected when data are generated from the fitted model and the posterior is computed correctly; it does not test whether real data follow that model. Conversely, poor SBC ranks can point to computation or implementation problems even when the model family is scientifically reasonable. Keep calibration, model adequacy, predictive performance, and algorithm reliability as separate conclusions.

Other warning signs include comparing scores calculated on different observations, using a single small validation set to claim a definitive winner, ignoring autocorrelation in posterior draws, and reporting narrow predictive intervals that condition on a fixed parameter estimate. If a candidate wins only in one simulation scenario, state that limitation. Results also depend on the parameter ranges, sampling schedules, and dose regimens included in the simulation design; extrapolating beyond those conditions needs separate evidence.

Key takeaway: A defensible workshop report states the data-generating scenarios, checks posterior computation and calibration, compares candidates on common predictive targets, and separates parameter uncertainty from observation-level uncertainty. No single diagnostic answers all four questions.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In an SBC replicate with six posterior draws, what are the possible ranks, and what is the expected rank if ranks are uniform?
  2. Why does a uniform SBC rank histogram not establish that a PK model is adequate for real data?
  3. Two candidates have log predictive densities \(-2.0,-1.0\) and \(-1.5,-1.2\) on the same two held-out observations. Which has the higher total score, and by how much?
  4. In the variance decomposition, what does the second term represent?
  5. Name two checks that can reveal unreliable posterior computation or numerical approximation.

Solutions. (1) The ranks are \(0,1,\ldots,6\), seven possible values. Their mean is \((0+6)/2=3\). (2) SBC generates data from the model being fitted, so it checks inference under that model and does not test whether the model describes real-world data. (3) The first total is \(-2.0-1.0=-3.0\); the second is \(-1.5-1.2=-2.7\). The second candidate scores higher by \(0.3\). (4) It is the posterior variance of the conditional predictive mean, representing uncertainty in predictions as parameters vary over their posterior distribution. (5) Examples include trace plots, effective sample sizes, \(\hat R\), independent-chain agreement, sampler warnings, and sensitivity to a smaller numerical time step.

Clinical Biostats