Tutorials › Optimal Design and Model-Informed Dosing › Simulation-Based Calibration for Bayesian Forecasting

Bayesian Forecasting and Dose Adaptation · Tutorial 348 of 497

Simulation-Based Calibration for Bayesian Forecasting

You will learn to simulate individual forecasting scenarios, interpret posterior rank histograms and interval coverage, and recognize what simulation-based calibration can—and cannot—establish.

Advanced 12 min read

What You'll Learn

  • Construct simulation-based calibration replicates for an individual Bayesian forecasting model.
  • Derive why the true parameter’s rank should be uniform under exact posterior computation.
  • Calculate a posterior rank and interpret rank histograms without overreading Monte Carlo variation.
  • Assess nominal coverage of posterior and predictive intervals across simulated individuals.
  • Distinguish computational calibration from model checking and validation against external data.
  • Identify how ties, correlated posterior draws, and incorrect simulation assumptions can undermine calibration.

Why Calibrate a Bayesian Forecasting Algorithm?

An individual forecasting algorithm may combine a population model, an individual’s concentration observations, and a posterior distribution for that individual’s parameters. It can then forecast a future concentration, AUC, Cmax, or the probability of meeting an exposure target. Even when the model is specified correctly, the computation that turns observations into a posterior can be wrong: a likelihood may be coded incorrectly, a parameter transformation may be mishandled, or posterior uncertainty may be understated.

Simulation-based calibration (SBC) is a way to test that computation under a known generative model. Repeatedly simulate an individual’s parameter values and observations, run the forecasting algorithm, and compare the simulated truth with its posterior distribution. If the model and computation meet the required conditions, the true parameter should occupy a uniform rank among posterior draws. Simulated interval coverage provides a complementary check of uncertainty summaries.

SBC is a test of the algorithm under the assumptions used to simulate. It is not, by itself, evidence that those assumptions describe patients in practice. That distinction matters in pharmacometrics: a forecasting method can pass SBC for its assumed individual PK model and still forecast poorly if real patients follow a different model.

Definition: In simulation-based calibration, each replicate is generated by drawing parameters from the model’s prior or population distribution, generating data from the specified sampling model, and applying the inference algorithm to those data. Calibration is assessed by comparing the simulated parameter truth with posterior draws, commonly using its rank, and by evaluating posterior or predictive uncertainty summaries across replicates.

What Must Be Simulated—and What Must Match?

For an individual forecasting algorithm, write \(\theta\) for the parameter or parameter vector being inferred for one individual, \(y\) for that individual’s observed data, and \(y^\ast\) for a future quantity to be forecast. A typical simulation replicate proceeds as follows:

  1. Draw \(\theta_0\) from the prior or population distribution used by the inference model.
  2. Generate the individual’s observed data \(y\) from the model conditional on \(\theta_0\).
  3. Run the forecasting algorithm using \(y\), obtaining posterior draws \(\theta^{(1)},\ldots,\theta^{(L)}\).
  4. Compare \(\theta_0\) with those draws, or evaluate posterior intervals and forecasts against their simulated truths.

The simulation and inference steps must correspond. If the inference model conditions on known population parameters, the simulation should use those same fixed values. If population parameters are estimated, simulate them according to the specified hierarchy and include them in the inference target as appropriate. Dose history, sampling times, residual error, and any assumed covariates also need to be generated consistently with the model being tested. This is a test of the implemented procedure under that model, not a test of every possible clinical data-generating process.

For the basic rank result, assume the simulated truth is drawn from the same prior used by the algorithm, the likelihood used to generate \(y\) is the likelihood used for inference, and the \(L\) posterior draws are independent draws from the exact posterior given \(y\). Assume also that the scalar quantity being ranked has a continuous posterior distribution, so ties occur with probability zero. These conditions make the truth and the posterior draws exchangeable conditional on \(y\): each has the same posterior distribution, and their order is equally likely.

Why the Rank Is Uniform

For a scalar parameter with continuous posterior distribution, define the rank of the simulated truth among \(L\) posterior draws by

$$ R=\sum_{\ell=1}^{L} I\!\left(\theta^{(\ell)}<\theta_0\right), \qquad R\in\{0,1,\ldots,L\}. $$

Here \(I(\cdot)\) equals 1 when its condition is true and 0 otherwise. The rank is the number of posterior draws below the truth. It is not a p-value, nor does a particular rank establish that the algorithm is calibrated. The calibration statement concerns the distribution of ranks across many independent simulation replicates.

Conditional on the simulated observations \(y\), the truth \(\theta_0\) has the posterior distribution \(p(\theta\mid y)\). Each exact posterior draw also has distribution \(p(\theta\mid y)\). Under the independence assumption, the \(L+1\) values are exchangeable, so each of the \(L+1\) possible order positions for the truth has probability \(1/(L+1)\). Therefore

$$ P(R=r\mid y)=\frac{1}{L+1}, \qquad r=0,1,\ldots,L. $$

This conditional result also holds after averaging over simulated datasets. Across \(S\) independent replicates, each rank has expected count \(S/(L+1)\). A histogram that is roughly flat is consistent with calibration, while systematic shapes can indicate bias or other computational problems. Random fluctuations are expected, especially with few replicates.

For vector parameters, ranks can be computed separately for each component, and they can also be computed for a scalar derived quantity such as clearance or a forecasted AUC. A component-wise rank check does not fully assess joint dependence or every derived forecast. Check quantities that matter to the intended forecast, not only parameters that are convenient to extract.

Worked Example: Ranking a Simulated Clearance Value

Consider a hypothetical individual model with \(\theta=\log(CL)\), where \(CL\) is clearance in L/h. For one simulation replicate, the simulated truth is \(\theta_0=0.40\). Suppose the algorithm returns five posterior draws, in log-clearance units: \(-0.10,\ 0.10,\ 0.30,\ 0.50,\ 0.80\). Calculate the rank.

The rank is the number of draws less than the truth:

$$ R=I(-0.10<0.40)+I(0.10<0.40)+I(0.30<0.40) +I(0.50<0.40)+I(0.80<0.40)=1+1+1+0+0=3. $$

Thus \(R=3\), one of the six possible ranks \(0,\ldots,5\). Under exact computation and the stated assumptions, each rank has probability \(1/6\) over repeated replicates. This one rank is not expected to be “near the middle” in any special sense; calibration is assessed using the rank distribution across many simulated individuals.

Checking Rank Histograms in Practice

The rank calculation is simple, but a useful diagnostic requires enough replicates and a clear account of posterior sampling. As a hypothetical illustration, take \(L=99\) posterior draws per replicate and \(S=1{,}000\) independent replicates. Group the 100 possible ranks into ten consecutive bins of ten ranks each. If ranks are uniform, the expected count in each bin is \(1{,}000/10=100\).

Worked Example: Interpreting a Rank Histogram

Suppose the ten bin counts are 92, 98, 105, 103, 97, 108, 96, 101, 99, and 101. They sum to 1,000. Under uniform ranks, the count in a bin has standard deviation approximately \(\sqrt{1{,}000(0.1)(0.9)}=9.49\). The observed differences from 100 are modest: the largest absolute difference is 8, less than one such standard deviation.

A useful numerical summary is the Pearson discrepancy from the expected counts:

$$ \sum_{j=1}^{10}\frac{(O_j-100)^2}{100} =\frac{64+4+25+9+9+64+16+1+1+1}{100} =1.94. $$

This small discrepancy is consistent with ordinary simulation variation; it does not prove that the algorithm is correct. Conversely, a visibly nonuniform pattern should prompt investigation rather than an immediate clinical conclusion. For example, ranks concentrated near the extremes can signal that posterior draws are systematically too narrow relative to the simulated truths. A trend from low to high ranks can be consistent with bias. The shape suggests where to look; it does not uniquely identify the cause.

A practical SBC run should track whether each replicate completed successfully, the parameterization in which ranks were calculated, and any numerical warnings. Examine ranks for important individual parameters and derived forecast targets separately. Repeat the exercise with enough replicates to distinguish a persistent pattern from Monte Carlo noise, and compare results across relevant designs, such as sparse and denser sampling schedules. A single pooled histogram can hide a failure confined to one design or subgroup.

The basic uniform-rank derivation assumes independent posterior draws. Markov chain Monte Carlo draws are usually autocorrelated, so treating a long correlated sequence as \(L\) independent draws can distort rank diagnostics even when the chain has the correct marginal distribution. Use an approach whose rank reference accounts for the sampling dependence, or use sufficiently independent posterior draws; thinning alone is not a guarantee of independence. For discrete parameters or quantities with posterior ties, use a prespecified randomized tie-breaking rule or a rank method designed for ties. Otherwise, apparent nonuniformity may arise from the rank construction rather than incorrect inference.

Checking Uncertainty Summaries

Ranks evaluate where the truth falls within posterior draws. Interval coverage asks a directly interpretable question: across repeated simulations, how often does an interval constructed by the algorithm contain the relevant simulated truth? If a procedure reports a nominal 95% posterior interval for a parameter, exact Bayesian computation under the prior-generative setup gives 95% prior-averaged coverage. This is a repeated-simulation property; it does not mean that a particular reported interval has a 95% probability of containing a fixed parameter.

For a forecast interval, the target must be clear. To assess a future concentration, simulate that future concentration from the model conditional on the simulated individual parameters and the planned dose and sampling time. Then check whether the algorithm’s predictive interval contains that simulated outcome. This tests the whole predictive computation, including the future observation model. An interval for a latent expected concentration and an interval for a future noisy measurement are different objects and need not have the same width or coverage.

Worked Example: Estimating 95% Interval Coverage

In a hypothetical SBC run, the algorithm reports a 95% posterior interval for an individual parameter in each of \(S=200\) independent replicates. The simulated truth falls inside 186 intervals. The estimated coverage is

$$ \widehat{C}=\frac{186}{200}=0.930. $$

If the true coverage were 0.95, the Monte Carlo standard error of this estimated proportion would be approximately

$$ SE(\widehat{C})=\sqrt{\frac{0.95(1-0.95)}{200}} =\sqrt{0.0002375}=0.0154. $$

The observed coverage is 0.020 below nominal, about \(0.020/0.0154=1.30\) Monte Carlo standard errors. This run alone is not strong evidence that coverage is wrong; more replicates or a more precise simulation assessment may be needed. Report the count, the denominator, the nominal level, and the Monte Carlo uncertainty rather than treating 93.0% as an exact property of the method.

What SBC Does Not Establish

SBC complements rather than replaces other forms of evaluation. The earlier material on calibration of individual predictive intervals addresses interval performance; SBC adds a controlled way to check whether the implemented Bayesian computation behaves as expected under its own generative assumptions. Posterior predictive checks instead compare features of observed data with data replicated from a fitted model. External validation evaluates forecasts against data not used to construct the model. These approaches answer different questions.

ApproachMain questionImportant limitation
Simulation-based calibrationDoes the computation recover the expected posterior behavior when data are generated by the assumed model?Cannot establish that the assumed model represents clinical reality.
Posterior predictive checksCan the fitted model reproduce relevant features of observed data?A satisfactory check does not prove that all forecasts are calibrated.
External forecast evaluationDo forecasts perform adequately on new observed individuals or outcomes?Requires suitable external data and can be affected by changes in population or practice.

A model can pass SBC and still be misspecified for real patients, because the simulation uses the assumed model by construction. SBC can also miss a failure if the tested parameter or derived quantity is not relevant to it, if too few replicates are run, or if posterior sampling error obscures the pattern. Treat results as evidence about a specified computational pipeline under specified simulated conditions, not as a universal certification.

Common Mistakes and Failure Modes

  • Interpreting one rank as a verdict. A single rank of 0 or \(L\) is allowed under a uniform rank distribution. Look for systematic patterns across replicates.
  • Simulating from a different model than the one used for inference. That may be useful for robustness studies, but it is not the basic SBC uniform-rank test. For that test, simulation and inference must use matching assumptions.
  • Calling prior-averaged coverage conditional coverage. Nominal interval coverage under prior-generated parameters averages over that prior. It does not guarantee nominal coverage for every fixed true parameter value or every clinical subgroup.
  • Ignoring Monte Carlo error. A coverage estimate a few percentage points below nominal can occur by chance when the number of replicates is modest. Quantify its simulation uncertainty.
  • Using correlated draws as if they were independent. The uniform-rank argument relies on exchangeability. Account for posterior-draw dependence when selecting or interpreting a rank procedure.
Key takeaway: In SBC, simulate truths and data from the model, run the individual forecasting algorithm, and assess ranks and uncertainty summaries over repeated replicates. Uniform ranks and nominal prior-averaged coverage support computational calibration under those assumptions; they do not demonstrate that the model is adequate for real clinical data.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. With \(L=19\) posterior draws and a continuous scalar parameter, what ranks are possible under the rank definition, and what is the probability of each rank under exact SBC conditions?
  2. A researcher simulates individual parameters from the model’s prior but generates concentration data with a residual-error distribution different from the likelihood used for inference. Should uniform ranks be expected from the basic SBC result? Why or why not?
  3. Across 100 independent replicates, 91 nominal 90% intervals contain the simulated truth. Calculate estimated coverage and its approximate Monte Carlo standard error under 90% coverage.
  4. Why can an algorithm pass SBC and still perform poorly on new patients?
  5. What assumption about posterior draws is used in the simple exchangeability derivation, and why can correlated MCMC draws complicate the rank histogram?

Solutions. (1) The possible ranks are 0 through 19, for 20 possible ranks. Each has probability \(1/20=0.05\) under the stated conditions. (2) No. The likelihood used to generate data does not match the inference model, so the truth and posterior draws are not guaranteed to be exchangeable conditional on the data; this is a model-mismatch stress test, not the basic uniform-rank test. (3) The estimated coverage is \(91/100=0.910\). The approximate Monte Carlo standard error under 90% coverage is \(\sqrt{0.90(0.10)/100}=\sqrt{0.0009}=0.0300\), or 3.00 percentage points. The observed estimate is close to nominal relative to this simulation uncertainty. (4) SBC tests computation under the model used to generate the simulations. If that model does not represent new patients, passing the computational test does not ensure accurate clinical forecasts. (5) The simple derivation assumes independent posterior draws, so the simulated truth and all draws are exchangeable conditional on the data. Correlated MCMC draws are not jointly exchangeable in that way, and their dependence can alter rank frequencies even when their marginal distribution is correct.

Clinical Biostats