Tutorials › Nonlinear Mixed-Effects Models (NLME) › Choosing the Number of Predictive Simulations

Visual and Numerical Predictive Checks · Tutorial 575 of 797

Choosing the Number of Predictive Simulations

Learn to plan predictive simulation counts by quantifying Monte Carlo precision and recognizing when apparent patterns may be simulation noise rather than model misfit.

Intermediate 11 min read

What You'll Learn

  • Explain why the number of independent simulated datasets controls Monte Carlo precision.
  • Approximate the Monte Carlo standard error of a simulated quantile or median.
  • Calculate how many replicates are needed for a chosen precision target.
  • Describe how finite simulation counts affect NPDE calculations.
  • Distinguish simulation noise from systematic predictive-check patterns.
  • Recognize when quantile precision formulas may not apply reliably.

Why the Number of Simulations Matters

A predictive check compares observed data with data generated under a fitted model. The simulated datasets provide a numerical approximation to the model’s predictive distribution; that approximation is itself subject to random variation. With too few simulations, a plotted median or quantile may move noticeably if the simulation is repeated, even when the model and observed data have not changed. Choosing the replicate count is therefore part of making the check stable enough to interpret.

The relevant count is the number of independent simulated replicates contributing to the quantity being estimated. A replicate is typically a simulated dataset generated under the intended design and model. Measurements within one dataset can be dependent, for example because they come from the same simulated subject. They should not automatically be counted as independent replicates when assessing the precision of a statistic calculated across datasets.

Definition: Monte Carlo error is the random error in a numerical estimate caused by using a finite number of random simulations. For an estimated quantity \(T\), its Monte Carlo standard error (MCSE) describes the standard deviation of that estimate over repeated, independent runs of the simulation procedure, with the model and simulation design held fixed.

MCSE is not the uncertainty in the model parameters, nor is it the sampling uncertainty that would arise from collecting a different study dataset. It quantifies only the numerical variability introduced by finite simulation. A small MCSE makes the predictive reference more reproducible; it does not establish that the model is adequate.

Monte Carlo Precision for Quantiles

Suppose \(R\) independent simulation draws are used to estimate the \(p\)-quantile \(q_p\) of a continuous predictive distribution with cumulative distribution function \(F\) and density \(f\). Assume \(0<p<1\), \(f(q_p)>0\), and that the density is reasonably smooth near \(q_p\). For sufficiently large \(R\), the empirical quantile has approximate variance

$$ \operatorname{Var}(\hat q_p)\approx \frac{p(1-p)}{R f(q_p)^2}, \qquad \operatorname{MCSE}(\hat q_p)\approx \sqrt{\frac{p(1-p)}{R f(q_p)^2}}. $$

Here \(\hat q_p\) is the quantile estimated from the simulations. The formula shows two important features. First, MCSE decreases in proportion to \(1/\sqrt{R}\): multiplying the replicate count by four approximately halves the MCSE. Second, quantiles are less precise where the predictive density is low. A small change in cumulative probability near such a quantile can correspond to a large change in the outcome value.

This approximation concerns independent draws from the predictive distribution, or independent replicate-level values when the target is a statistic calculated once per simulated dataset. If observations are clustered within simulated subjects or datasets, the dependence structure matters. The formula should not be applied as though every measurement were independent when the estimate is based on clustered measurements.

Why the Quantile Formula Works

A short approximation explains the formula. At the true quantile, \(F(q_p)=p\). The empirical cumulative distribution function at \(q_p\), denoted \(\hat F_R(q_p)\), is an average of \(R\) indicator variables: each is one if its draw is at or below \(q_p\), and zero otherwise. Each indicator has success probability \(p\), so

$$ \operatorname{Var}\{\hat F_R(q_p)\}=\frac{p(1-p)}{R}. $$

For a small displacement \(\delta\) from \(q_p\), smoothness of the density gives \(F(q_p+\delta)\approx p+f(q_p)\delta\). Thus, to first order, an error in cumulative probability is converted to an error in the quantile by dividing by \(f(q_p)\). Applying that local conversion to the variance above gives

$$ \operatorname{Var}(\hat q_p)\approx \frac{\operatorname{Var}\{\hat F_R(q_p)\}}{f(q_p)^2} =\frac{p(1-p)}{R f(q_p)^2}. $$

This is a large-sample approximation, not an exact guarantee for every finite simulation. It can be unreliable for very small \(R\), very sparse tails, a density close to zero near the target quantile, or discrete predictive outcomes with many ties.

Worked Example: Precision of a Simulated Lower Quantile

Suppose 500 independent simulated replicates are used to estimate the 10th percentile of a hypothetical concentration summary. Near that percentile, the predictive density is estimated as \(0.0878\) per mg/L. Approximate the MCSE of the estimated quantile.

Set \(p=0.10\), \(R=500\), and \(f(q_p)=0.0878\) per mg/L. The units of the resulting quantile MCSE are mg/L:

$$ \operatorname{MCSE}(\hat q_{0.10}) \approx \sqrt{\frac{0.10(1-0.10)}{500(0.0878)^2}} =\sqrt{\frac{0.09}{3.85442}} \approx 0.1528\ \text{mg/L}. $$

The denominator is \(500(0.0878)^2=3.85442\). Under the approximation, simulation noise alone gives a standard error of about \(0.153\) mg/L for this estimated percentile. The result is not a confidence interval for the model’s true parameter, and it does not describe uncertainty in the observed study.

Worked Example: Planning Replicates for a Median

For a hypothetical simulated outcome, suppose the predictive density near its median is \(0.20\) per hour. Compare the approximate median MCSE for \(R=400\) and \(R=1600\) independent simulated values.

For the median, \(p=0.50\), so \(p(1-p)=0.25\). With 400 replicates:

$$ \operatorname{MCSE}(\hat q_{0.50}) \approx \sqrt{\frac{0.25}{400(0.20)^2}} =\sqrt{\frac{0.25}{16}} =0.125\ \text{hour}. $$

With 1600 replicates:

$$ \operatorname{MCSE}(\hat q_{0.50}) \approx \sqrt{\frac{0.25}{1600(0.20)^2}} =\sqrt{\frac{0.25}{64}} =0.0625\ \text{hour}. $$

The replicate count increased fourfold and the estimated MCSE halved, as the \(1/\sqrt{R}\) relationship predicts. If the target were an approximate median MCSE no greater than \(0.05\) hour, solving the same formula gives

$$ R\geq \frac{0.25}{(0.05)^2(0.20)^2}=2500. $$

This planning calculation is only as reliable as the density estimate and the quantile approximation. In practice, it is sensible to check stability using independent simulation batches as well.

Simulation Counts and NPDE

Normalized prediction distribution errors (NPDE) use simulated predictive distributions to express observed deviations on a standardized, decorrelated scale. Their detailed transformation is treated in the later material on NPDE. For choosing the number of simulations, the important point is that the predictive distribution’s finite-simulation estimates—such as its location, covariance, or probability assigned to an observed value—can vary from one simulation run to another. That variation can carry through to the calculated NPDE.

The familiar quantile MCSE formula is useful for a probability or quantile estimated from independent simulation draws, but it does not by itself give the MCSE of every NPDE calculation. In particular, covariance estimates and transformations involving several correlated observations can have more complicated finite-simulation behavior. A simple illustration is the estimated fraction of simulated values below an observation. If the true predictive probability is \(p\), its Monte Carlo standard error is approximately \(\sqrt{p(1-p)/R}\). A normal-scale score based on that estimated probability will also vary; the amount depends on the probability’s location and on the transformation. Tail probabilities deserve care because a small probability error can produce a substantial score change.

Worked Example: Finite-Simulation Variation in a Predictive Probability

In a hypothetical calculation, the predictive probability that a simulated value falls below an observed value is \(0.25\). Estimate the MCSE of the simulated probability using 400 replicates, then compare it with 1600 replicates.

For \(R=400\), the binomial approximation gives

$$ \operatorname{MCSE}(\hat p) \approx \sqrt{\frac{0.25(0.75)}{400}} =\sqrt{0.00046875} \approx 0.02165. $$

For \(R=1600\):

$$ \operatorname{MCSE}(\hat p) \approx \sqrt{\frac{0.25(0.75)}{1600}} =\sqrt{0.0001171875} \approx 0.01083. $$

For scale, if this probability is mapped to a standard normal score by \(z=\Phi^{-1}(p)\), a local first-order approximation gives \(\operatorname{SE}(\hat z)\approx \operatorname{SE}(\hat p)/\phi(z)\), where \(\Phi\) and \(\phi\) are the standard normal cumulative distribution function and density. At \(p=0.25\), \(z\approx -0.6745\) and \(\phi(z)\approx0.3178\), giving approximate score errors of \(0.02165/0.3178\approx0.0681\) and \(0.01083/0.3178\approx0.0341\), respectively. This is an illustration of finite-simulation sensitivity, not a replacement for the specific NPDE algorithm or its dependence-aware assessment.

Checking Whether a Pattern Is Simulation Noise

A predictive check can show irregular wiggles even when its underlying target is stable. Conversely, a persistent discrepancy may remain after simulation noise has been reduced. A practical assessment asks whether the feature is reproducible across independent runs and whether its size is plausible relative to the MCSE.

1
Identify the simulated quantity.
Specify whether the check uses a median, a tail quantile, a probability, a replicate-level summary, or an NPDE-related estimate. State which independent simulation replicates contribute to it.
2
Assess its precision.
Use an appropriate MCSE approximation where its assumptions hold. For quantiles, account for the density near the target quantile; for an estimated probability, use the binomial standard error as a starting point.
3
Repeat with independent batches.
Compare the estimated summaries from separate simulation batches, or compare estimates after increasing the replicate count. Changes on the scale expected from MC error suggest numerical noise; persistent, similarly directed differences merit substantive investigation.
4
Interpret the pattern in context.
Consider its magnitude, direction, and reproducibility, as well as the model and design. A noisy plot is not evidence of model failure by itself, and a stable plot is not proof that all model assumptions are correct.

Look especially carefully at extreme quantiles, where few simulated values determine the estimate, and at intervals or time regions with limited information. Quantile estimates that jump between batches, disappear as the replicate count rises, or change direction repeatedly are warning signs of simulation noise. Systematic departures that persist across independent batches are less easily explained by Monte Carlo variability alone, though they still require scientific interpretation.

Choosing a Count and Avoiding Common Errors

A useful planning rule follows directly from the quantile formula. If an approximate MCSE no larger than \(\delta\) is desired, then

$$ R\geq \frac{p(1-p)}{\delta^2 f(q_p)^2}. $$

The target \(\delta\) should be chosen in the units and context of the check: for example, small relative to a clinically meaningful concentration difference or to the visual resolution needed to distinguish a trend. If \(f(q_p)\) is unknown, a pilot simulation can provide a provisional density estimate, followed by a larger run and a stability check. The final count should be large enough for the key summaries, not merely convenient for one central statistic.

Increasing the number of simulations reduces Monte Carlo error, but it does not repair model misspecification, biased parameter estimates, an inappropriate predictive target, or a poorly chosen analysis. It also costs computation. Alternatives or complements include comparing independent batches, estimating MCSE directly for the summary of interest, or using a justified analytic calculation where available. These approaches diagnose precision; they do not make finite simulation error vanish.

  • Do not confuse simulation replicates with observations. Measurements from the same simulated subject or dataset may be dependent; treating them as independent can understate uncertainty.
  • Do not assume all quantiles have equal precision. The density near the quantile matters, so a tail quantile can be substantially less stable than the median.
  • Do not call Monte Carlo error model uncertainty. More simulations stabilize the numerical approximation under the specified model; they do not account for uncertainty about the model or its parameters.
Common mistake: “The simulated median changed when I reran the check, so the model must be unstable.” The change may simply be Monte Carlo error. Estimate or assess the summary’s simulation precision and compare independent batches; only a reproducible discrepancy should be interpreted as a persistent predictive pattern.

The central practical lesson is to make simulation precision commensurate with the question. A replicate count that is adequate for a median may be inadequate for a tail quantile or a simulation-based normal score. Precision should be evaluated for the specific summaries used in the check, while keeping Monte Carlo variability distinct from uncertainty and model misfit.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. If the replicate count increases from 500 to 2000, by what factor does the approximate MCSE of a regular quantile change?
  2. Why can a 10th percentile be less precise than a median even when both use the same number of simulations?
  3. For \(R=1000\), \(p=0.20\), and \(f(q_p)=0.10\) per unit, calculate the approximate quantile MCSE.
  4. Why should 50 measurements from one simulated dataset not automatically be counted as 50 independent simulation replicates?
  5. Name one way to check whether a visible predictive-check wiggle could be simulation noise.

Solutions. (1) The count is multiplied by four, so MCSE is approximately halved. (2) The density may be lower near the 10th percentile; since MCSE is inversely proportional to \(f(q_p)\), lower density means greater error. (3) \(\sqrt{0.20(0.80)/[1000(0.10)^2]}=\sqrt{0.016}\approx0.1265\) units. (4) Measurements within a dataset may be dependent, so the independent simulation unit is the replicate dataset, not necessarily each measurement. (5) Repeat the check in independent simulation batches and compare the summaries, or increase the replicate count and assess whether the feature persists.