Tutorials › Multi-Arm Multi-Stage (MAMS) Designs › Quantifying Monte Carlo Error in Posterior Probabilities

Bayesian Multi-Arm Approaches · Tutorial 419 of 499

Quantifying Monte Carlo Error in Posterior Probabilities

You will learn to quantify simulation error in posterior decision probabilities and use an interval around the estimate to assess whether a decision threshold has been clearly crossed.

Advanced 12 min read

What You'll Learn

  • Estimate Monte Carlo error for posterior event probabilities from independent draws.
  • Adjust the standard error for autocorrelation in an MCMC indicator sequence.
  • Construct and interpret approximate Monte Carlo intervals.
  • Decide whether simulation precision is sufficient relative to a decision threshold.
  • Recognize boundary problems and other signs that an error estimate may be unreliable.

Why quantify simulation error?

A posterior decision rule may depend on a probability such as the posterior chance that an arm’s benefit exceeds a clinically meaningful threshold. In practice, that probability is often estimated from simulated posterior draws. The estimate is itself subject to simulation error: a different run of the simulation would generally give a slightly different value, even if the data, model, and posterior distribution were unchanged.

This error matters when the estimated probability is close to a decision cutoff. An estimate just above the cutoff is not persuasive evidence that the underlying posterior probability is above it if simulation noise is large. Monte Carlo standard errors (MCSEs) and intervals quantify this numerical uncertainty. They do not quantify uncertainty about the treatment effect itself; that uncertainty is already represented by the posterior distribution.

Estimating a posterior decision probability

Let \(y\) denote the observed data, and let \(A\) be the event that defines a decision-relevant posterior probability. For example, \(A\) might be the event that an arm’s treatment effect exceeds a specified benefit threshold. The target is \(p=P(A\mid y)\). Given \(M\) posterior draws, define \(I_m=1\) if draw \(m\) satisfies \(A\), and \(I_m=0\) otherwise. The simulation estimate is the average of these indicators.

Definition: The estimated posterior decision probability is \(\hat p=M^{-1}\sum_{m=1}^{M} I_m\). Its Monte Carlo standard error (MCSE) estimates the standard deviation of \(\hat p\) over repeated simulations targeting the same posterior distribution. It measures simulation error, not posterior uncertainty about the underlying treatment effect.

If the posterior draws are independent, the indicators are independent Bernoulli variables with success probability \(p\). Their variance is \(p(1-p)\), so the variance of their average is \(p(1-p)/M\). Replacing the unknown \(p\) by \(\hat p\) gives the usual estimated MCSE:

$$ \widehat{MCSE}_{\mathrm{iid}} = \sqrt{\frac{\hat p(1-\hat p)}{M}}. $$

This formula applies to genuinely independent posterior draws. MCMC draws are generally dependent, so treating their count as if it came from \(M\) independent draws can understate the error.

Worked Example: Independent Posterior Draws

Suppose 10,000 independent posterior draws are used to estimate the probability that a hypothetical treatment arm exceeds the prespecified benefit threshold. The event occurs in 7,200 draws. Thus \(\hat p=7,200/10,000=0.7200\).

The estimated MCSE is

$$ \widehat{MCSE} = \sqrt{\frac{0.7200(1-0.7200)}{10{,}000}} = \sqrt{0.00002016} \approx 0.004490. $$

An approximate 95% Monte Carlo interval is \(\hat p\pm1.96\widehat{MCSE}\). Using the unrounded MCSE, its margin is \(1.96(0.004489989)\approx0.0088004\), giving

$$ 0.7200\pm0.0088004 \quad\Longrightarrow\quad (0.7112,\ 0.7288). $$

This interval describes the approximate simulation uncertainty around the estimated posterior probability. It is not a 95% posterior credible interval for the treatment effect. If the decision cutoff were 0.70, the entire interval would exceed that cutoff, suggesting that the simulation estimate is precise enough to support the probability comparison.

Accounting for MCMC dependence

For MCMC, the indicator sequence \(I_1,\ldots,I_M\) can be autocorrelated even when the chain has reached its target distribution. Let \(\gamma_k\) be the lag-\(k\) autocovariance of the indicator sequence, and let \(\rho_k=\gamma_k/\gamma_0\) be its lag-\(k\) autocorrelation. For a stationary chain, the variance of the sample average is

$$ \operatorname{Var}(\hat p) = \frac{\gamma_0}{M} \left[ 1+2\sum_{k=1}^{M-1} \left(1-\frac{k}{M}\right)\rho_k \right]. $$

The bracketed factor accounts for dependence. When positive autocorrelation persists across lags, it is greater than one, so the variance exceeds the independent-draw variance \(\gamma_0/M\). For an indicator with marginal probability \(p\), \(\gamma_0=p(1-p)\). In practice, the autocovariances are estimated from the simulated indicator sequence, using a suitable spectral-variance or batch-means estimator.

A useful summary is the effective sample size for the indicator sequence, denoted here by \(ESS_I\). It is the number of independent Bernoulli draws that would give approximately the same variance as the correlated simulation. The corresponding approximation is

$$ ESS_I \approx \frac{M}{1+2\sum_{k=1}^{\infty}\rho_k}, \qquad \widehat{MCSE} \approx \sqrt{\frac{\hat p(1-\hat p)}{ESS_I}}. $$

In applications, the infinite sum is estimated with a method that controls the effect of noisy high-lag autocorrelations. Use the ESS and MCSE for the decision indicator, not automatically the ESS for a treatment-effect parameter: the chain can mix differently for a threshold event than for a continuous parameter.

Worked Example: Dependence Reduces Effective Information

Suppose an MCMC run produces 12,000 retained draws, and the decision event occurs in 7,680 of them, so \(\hat p=0.6400\). The estimated effective sample size of the indicator is 3,000, reflecting serial dependence.

Using the indicator ESS gives

$$ \widehat{MCSE} \approx \sqrt{\frac{0.6400(1-0.6400)}{3{,}000}} = \sqrt{0.0000768} \approx 0.008764. $$

The approximate 95% Monte Carlo interval is

$$ 0.6400\pm1.96(0.00876356) = 0.6400\pm0.01718 \approx(0.6228,\ 0.6572). $$

A naive independent-draw calculation using all 12,000 draws would give an MCSE of about \(\sqrt{0.2304/12{,}000}=0.004382\), substantially smaller than the dependence-adjusted estimate. If the decision cutoff is 0.65, the MCMC interval straddles it. The point estimate alone does not establish that the target probability is above or below the cutoff with the chosen level of simulation precision.

Intervals and threshold-based decisions

When the estimate is not too close to zero or one and the simulation is sufficiently regular, a normal approximation gives an approximate \(100(1-\alpha)\%\) Monte Carlo interval:

$$ \hat p \pm z_{1-\alpha/2}\widehat{MCSE}, $$

where \(z_{1-\alpha/2}\) is the corresponding standard normal quantile. For a 95% interval, it is approximately 1.96. The interval is an approximation to repeated-simulation uncertainty in \(\hat p\), conditional on the data and posterior target. It is not a posterior interval for an effect, and it is not a probability statement that the fixed target \(p\) has a particular chance of lying in this realized interval.

For a rule that compares \(p\) with a cutoff \(c\), the interval gives a direct precision check. If its lower endpoint is greater than \(c\), the simulation supports \(p>c\) at the approximate interval level; if its upper endpoint is less than \(c\), it supports \(p<c\). If the interval overlaps \(c\), the simulation has not resolved the comparison at that precision. That does not prove \(p=c\): more simulation may narrow the interval, or the posterior probability may genuinely be close to the threshold.

Worked Example: Is the Simulation Precise Enough?

For a hypothetical arm, suppose an MCMC analysis estimates the probability of satisfying the decision event as \(\hat p=0.7800\), with indicator effective sample size \(ESS_I=8{,}000\). The decision rule requires this probability to exceed 0.75.

The MCSE and 95% Monte Carlo interval are

$$ \widehat{MCSE} \approx \sqrt{\frac{0.7800(0.2200)}{8{,}000}} = \sqrt{0.00002145} \approx 0.004631, $$
$$ 0.7800\pm1.96(0.004631) \approx (0.7709,\ 0.7891). $$

The lower endpoint, 0.7709, exceeds 0.75. Under the normal approximation, simulation error is small enough to distinguish the estimated probability from the cutoff in the upward direction. This conclusion concerns numerical precision only; it does not validate the model, prior, or decision rule.

Choosing a precision target and checking the calculation

A useful simulation plan specifies a precision target before inspecting the final result. For example, one may require the Monte Carlo interval’s half-width to be no more than \(h\), or require the interval to lie entirely on one side of a decision cutoff. Under the independent-draw approximation, a rough effective sample size requirement for half-width \(h\) is

$$ ESS_I \ge \frac{z_{1-\alpha/2}^{\,2}\hat p(1-\hat p)}{h^2}. $$

Because the required size depends on \(p\), planning may use a conservative value such as \(p=0.5\), which maximizes \(p(1-p)\), or a plausible value from pilot simulation. For MCMC, the target is an effective sample size, not merely a raw number of saved iterations.

As a short justification, the interval half-width is \(h=z_{1-\alpha/2}\sqrt{\hat p(1-\hat p)/ESS_I}\). Requiring it to be at most a chosen \(h\), squaring both nonnegative sides and rearranging gives the displayed ESS requirement. For example, with \(\hat p=0.70\), a 95% half-width target of 0.01 requires approximately

$$ ESS_I \ge \frac{1.96^2(0.70)(0.30)}{0.01^2} = 8{,}067.36, $$

so an effective sample size of about 8,068 or greater is a rough target. This is a planning calculation, not a guarantee: the realized ESS estimate and chain diagnostics still need inspection.

Diagnostics, limitations, and alternatives

Before trusting an MCSE, check whether the simulation is credible for the event being estimated. The convergence and mixing diagnostics considered in the earlier material on diagnosing MCMC near decision boundaries remain relevant. In particular, inspect the indicator trace, compare chains, and check for long stretches in which the event status barely changes. A chain can appear well behaved for a parameter while rarely crossing the decision boundary, leaving the indicator ESS small and its MCSE unreliable.

  • Do not use the raw iteration count as an independent sample size. Autocorrelation can make the effective information much smaller than \(M\).
  • Do not report an MCSE without identifying what was monitored. The relevant series is the zero-one indicator of the decision event.
  • Be cautious near zero or one. A normal interval can extend outside \([0,1]\), and if every simulated indicator is zero or every one, the plug-in MCSE is zero even though the true probability need not be exactly zero or one. More simulation and appropriate boundary-aware methods may be needed.
  • Do not confuse precision with correctness. A tiny MCSE does not remedy a misspecified model, an unsuitable prior, a coding error in the event, or poor chain exploration.

For independent Bernoulli draws, a Wilson interval is one alternative to the simple normal interval, especially when the estimated probability is near a boundary. For MCMC draws, ordinary binomial intervals that treat every iteration as independent are generally inappropriate; dependence-aware variance estimation is needed. Increasing the number of iterations can improve precision, but only if the chain explores the relevant posterior region. The central practical comparison is therefore not “many draws versus few draws,” but “adequate effective information and diagnostics versus inadequate effective information.”

Key takeaway: Estimate the posterior event probability with an indicator average, estimate its MCSE using independent-draw or dependence-adjusted calculations as appropriate, and compare an interval for simulation error with the decision cutoff. If the interval overlaps the cutoff, report the comparison as unresolved at the achieved simulation precision.

Check Your Understanding

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

  1. From 5,000 independent posterior draws, an event occurs 3,000 times. Calculate \(\hat p\) and its estimated MCSE.
  2. An MCMC run has 10,000 retained draws, but the decision-indicator ESS is 2,500. Why is the ESS, rather than 10,000, used in the approximate MCSE calculation?
  3. An estimated posterior decision probability is 0.61, with a 95% Monte Carlo interval of (0.58, 0.64). What can be concluded about a cutoff of 0.60?
  4. Why can an estimated MCSE of zero be misleading if all simulated indicators equal zero?

Solutions. (1) \(\hat p=3{,}000/5{,}000=0.6000\). The MCSE is \(\sqrt{0.60(0.40)/5{,}000}=\sqrt{0.000048}\approx0.006928\). (2) The MCMC draws are correlated, so 10,000 iterations do not generally contain the information of 10,000 independent draws. The indicator ESS accounts approximately for that dependence; here the MCSE uses \(\sqrt{\hat p(1-\hat p)/2{,}500}\). (3) The interval overlaps 0.60, so the simulation does not resolve whether the target probability is above or below the cutoff at this approximate 95% level. It does not establish that the target equals 0.60. (4) The plug-in formula uses \(\hat p(1-\hat p)\), which is zero when \(\hat p=0\). But a finite simulation with no event draws does not prove the target probability is zero, and the normal approximation is unreliable at the boundary.

Clinical Biostats