Documentation

41.30 Case 7: three checks on a simulation before it is trusted

Three checks on a simulation before it is trusted

What you will learn

  • Switch every source of randomness off, and verify the simulator against a closed-form calculation done by hand.
  • Add parameter uncertainty and say what the bundle can and cannot show about its effect.
  • Simulate the design of an existing data set, and reproduce the run from a settings file.
  • Recognise a note that changes how a metric must be read.

Prerequisites: 41.28 and 41.29.

The question: the previous two pages used a simulator to answer dose questions. Why should the numbers be believed?

The evidence: four Chapter 28 bundles, typical_subject, parameter_uncertainty, own_design and own_design_final. All simulate the covariate model of Case 5.

Check 1: the typical subject, against a pencil calculation

If the simulator is correct, then with every random element removed it must reproduce a result that can be computed by hand. The typical_subject bundle removes them all:

nlmx sims run28.ctl --ext run26.ext --estimates final \
  --subjects 24 --subproblems 5 --seed 28007 --population adult \
  --covariate "EGFR=constant(95)" --adult-weight-mean 70 --adult-weight-sd 0.01 \
  --sim-etas zero --sim-eps zero --omega-scale 0 --sigma-scale 0 \
  --dose 100 --tau 24 --grid-points 481 --conc-at 2,6

--sim-etas zero --sim-eps zero sets the between-subject and residual random effects to zero; --omega-scale 0 --sigma-scale 0 removes them from the variance model as well; the weight is fixed at 70 kg (an SD of 0.01 kg, effectively constant) and the eGFR at 95. All 24 × 5 = 120 simulated subjects are the same subject. The stored summary confirms it: every metric has a standard deviation of about 10⁻¹⁵ (for Cmax, 1.8 × 10⁻¹⁵), which is rounding error, not variability.

The calculation

The model is a one-compartment model with first-order absorption. For a subject with these covariates, using the estimates of Case 5 (typical clearance 4.275102 L/h, volume 45.4789 L, absorption rate 1.182401 h⁻¹, weight exponents 0.7268318 on clearance and 1.010023 on volume, eGFR exponent 0.5776152, reference weight 72.2047 kg and reference eGFR 93.62222):

\[\text{CL} = 4.275102\left(\tfrac{70}{72.2047}\right)^{0.7268318}\left(\tfrac{95}{93.62222}\right)^{0.5776152} = 4.2152 \text{ L/h},\]
\[V = 45.4789\left(\tfrac{70}{72.2047}\right)^{1.010023} = 44.0765 \text{ L}, \qquad k = \frac{\text{CL}}{V} = 0.095635\ \text{h}^{-1}.\]

The terminal half-life is ln 2 / k = 7.25 h. After many doses of D = 100 mg every τ = 24 h the concentration within an interval is

\[C(t) = \frac{D\,K_A}{V\,(K_A - k)}\left[\frac{e^{-kt}}{1-e^{-k\tau}} - \frac{e^{-K_A t}}{1-e^{-K_A \tau}}\right], \qquad 0 \le t \le \tau,\]

the usual steady-state curve. The peak is at the time where its derivative vanishes,

\[t_{max} = \frac{1}{K_A - k}\,\ln\!\frac{K_A\,(1-e^{-k\tau})}{k\,(1-e^{-K_A\tau})},\]

and the average over the interval is Dose/(CL·τ). Evaluating them:

Quantity By hand From the run
CL at steady state (L/h) 4.2152 4.215
Cmax (mg/L) 2.0411 2.041
Tmax (h) 2.2163 2.2
Cmin = C(0) = C(24) 0.27652 0.2765
CAVG (mg/L) 0.98848 0.9885
AUC over 24 h 23.723 23.72
C at 2 h 2.0351 2.035
C at 6 h 1.5444 1.544

Every row agrees to the digits the program prints. The one entry that looks different, the time of the peak (2.2163 against 2.2), has a reason: --grid-points 481 evaluates the curve on a grid of 24/480 = 0.05 h, and the nearest grid point to 2.2163 is 2.20. At that grid point the hand-computed concentration is 2.04103, against 2.04106 at the exact maximum: the same to five digits. A time of peak read from a grid is quantised to the grid, which is worth remembering on every page where a Tmax appears.

This check is more valuable than it looks. It does not test the model (the estimates are assumed); it tests the machinery: the covariate equations, the steady-state superposition, the metric definitions and the interval. A simulator that fails it has a bug that no amount of Monte Carlo averaging will reveal.

Check 2: parameter uncertainty

In the earlier runs the parameters are fixed at their estimates. The parameter_uncertainty bundle adds the covariance matrix of the fit (run26.cov) and --param-uncertainty: each of the 30 simulations draws its own parameter set from a multivariate normal around the estimates.

--cov run26.cov --param-uncertainty --subjects 32 --subproblems 30 --seed 28005 \
--population adult --covariate "EGFR=normal(95,20)[30,160]" --dose 100 --tau 24
Group CAVG 0.6–1.4 Across simulations
All (960 subjects) 87.92 % (844 of 960) 75–96.88
Sex 0 86.46 % (415 of 480) 73.28–100
Sex 1 89.38 % (429 of 480) 73.28–100

The spread of the simulation mean of CAVG is stored as well: median 0.9889, with a 95 % range of 0.9093–1.047 across the 30 simulations. Thirty-two subjects with a CAVG standard deviation of 0.27 would produce a range of about ±1.96 × 0.27/√32 = ±0.09 around the mean with no parameter uncertainty at all, and the observed half-width (0.069) is no larger. So at the precision of this fit, parameter uncertainty adds no visible spread to the simulation mean beyond what the sampling of subjects already adds. That is a statement about this fit, whose three covariate exponents have standard errors of 0.12–0.16, and it need not hold for a model with a poorly determined exponent.

What the bundle cannot say is how much wider the attainment range is than without uncertainty: it has no twin run with the same design and seed and uncertainty off. A page that says "uncertainty widens the range" would need that pair; the right way to show it is two runs that differ in nothing but the one switch.

Check 3: your own design

The third bundle simulates the study that already exists. --data analysis.csv gives the 60 subjects and 480 observations of Case 5; instead of generating a population, the run uses each subject's own weight, eGFR and sex, and their own sampling times:

nlmx sims run26.ctl --data analysis.csv --ext run26.ext --estimates final \
  --subproblems 12 --seed 28006 --sim-eps zero \
  --metric-profile observed --metric-interval first --tau 24 \
  --metrics CMAX,TMAX,CMIN,TMIN,CTROUGH,CAVG,AUCTAU \
  --summary-by SEX --targets "CAVG:0.6-1.4"

The ETAs are sampled afresh (--sim-etas is not changed, so it stays at its default of sampling), the residual error is zero, and 12 simulations of the 60 subjects give 720 subject-profiles. The metrics are computed only from the subjects' observed sampling times (--metric-profile observed) and over the first dosing interval, as these subjects received a single dose.

Metric Mean P5 P95
Cmax 1.859 1.212 2.714
Cmin 0.2676 0.0835 0.5024
CAVG 0.8915 0.5818 1.273
AUC over the interval 21.40 13.96 30.55

Target attainment: 91.25 % of 720 (657) inside 0.6–1.4 mg/L, with 88.33–94.54 % across simulations; women 90.28 % (325 of 360), men 92.22 % (332 of 360).

The note that matters

The summary carries a line that is easy to skip:

720 subject interval(s) are not covered by the sampled profile; their areas are those of the part covered.

It says that the metrics were computed from a profile that does not span the whole interval for any of the 720 subjects, so each AUC is the area of the part that was sampled. Two consequences. First, these CAVG and AUC values are not comparable with the dense-profile, steady-state values of the previous pages (CAVG about 1.0): a single dose averaged over its first day is lower than a steady-state average, and an incompletely sampled profile lowers it further. Second, the right comparison for this run is with itself: the question it answers is what the observed design would have measured, which is what a design review wants. Always read the notes block before quoting a number from a sims summary.

Reproducing the run from a settings file

The same run is stored a second time, as own_design_final, executed from the settings file own-design.sims (it holds the control stream, the data file, the estimates file, the seed 28006, 12 simulations, the metrics, the summary and the target) with the one-line command nlmx sims -c own-design.sims -o own_design_final. The two output folders were compared file by file: the per-subject metric files and the summary files are byte-identical. That is the reproducibility contract of Chapter 42 (page 42.13) in a case: the settings file is the experiment, and a reviewer can re-run it without the author's command line.

The decision

Question Evidence Decision Reversible?
Does the simulator reproduce a pencil calculation? eight quantities agree to the printed digits yes; the machinery is trusted yes
Does parameter uncertainty change the conclusion? 87.92 %; range of the simulation mean no wider than sampling alone not visibly, for this model; no paired run to quantify yes
Can the own-design run be reproduced? byte-identical files from the settings file yes yes
Can its attainment be compared with the steady-state runs? single dose, partly covered profile no yes

What this case does not show

The closed form checks a typical subject, not the distribution of random effects, whose correctness is a statistical, not an exact, question (the Monte Carlo checks of Chapter 42, page 42.11). The parameter-uncertainty bundle has no control run, and the own-design bundle is a single-dose, observed-time design. None of the three says the model is right, which is the job of the checks of Case 6.

Review checklist

  • Have you run the simulator with all randomness off and compared at least one quantity with a hand calculation?
  • Do you know what grid a reported Tmax was read from?
  • Do you have a paired run, with one switch changed, before you claim an effect of that switch?
  • Did you read the notes of the summary before quoting a metric, and do you say whether it comes from a dense or an observed profile?
  • Can another person re-run the run from a settings file and get the same files?

See the previous page, the next page and the complete case-study reference.