Tutorials › Quantitative Systems Pharmacology (QSP) › Tuning Random-Walk Metropolis Proposals

Bayesian Calibration and Uncertainty Quantification · Tutorial 643 of 799

Tuning Random-Walk Metropolis Proposals

Tune random-walk Metropolis proposals for mechanistic calibration by balancing movement and acceptance, accounting for posterior scale and correlation, and checking chain behaviour.

Advanced 12 min read

What You'll Learn

  • Define a random-walk proposal on the parameter scale used for sampling.
  • Interpret acceptance rates as tuning evidence, not as proof of convergence.
  • Adjust proposal scale using trace behaviour and effective sample size.
  • Use pilot covariance estimates to choose proposal direction and relative scale.
  • Identify failures caused by poor scaling, correlation, boundaries, or unstable adaptation.
  • Compare isotropic, diagonal, and covariance-aware random-walk proposals.

Why Proposal Tuning Matters

In a mechanistic calibration, a posterior distribution may have parameters with very different scales and strong dependence. A random-walk Metropolis proposal that is too small tends to be accepted but makes slow progress through that posterior. A proposal that is too large tends to be rejected, leaving the chain repeatedly at its current value. Tuning aims to make useful movement, not to maximize acceptance.

This tutorial assumes the Metropolis-Hastings update and posterior target have been introduced. Let \(\theta\) denote the vector of parameters on the scale used by the sampler, and let \(\pi(\theta)\) be its posterior density. In QSP calibration, evaluating \(\pi(\theta)\) may require solving an ODE model and evaluating an observation likelihood. Proposal tuning can therefore materially affect computational efficiency, even though it does not change the posterior target when the Metropolis-Hastings correction is applied correctly.

Definition: A random-walk Metropolis proposal has the form \(\theta'=\theta+\varepsilon\), where the increment \(\varepsilon\) is drawn from a distribution centred at zero. A common choice is \(\varepsilon\sim N(0,\Sigma_q)\), where \(\Sigma_q\) is the proposal covariance matrix. For a symmetric proposal, the proposed value is accepted with probability \(\min\{1,\pi(\theta')/\pi(\theta)\}\); otherwise the chain remains at \(\theta\).

For numerical work, the log acceptance ratio is usually evaluated as \(\log \pi(\theta')-\log \pi(\theta)\). The proposal is accepted if this difference is nonnegative, and otherwise is accepted with probability \(\exp\{\log \pi(\theta')-\log \pi(\theta)\}\). The acceptance rate over a run is the number of accepted transitions divided by the number of attempted transitions, including rejected proposals in the denominator.

What a Tuning Change Can and Cannot Do

Proposal tuning changes how the chain explores the target, not the target itself. If a fixed, symmetric proposal is used with the correct Metropolis-Hastings acceptance probability, detailed balance holds:

$$ \pi(\theta)q(\theta'\mid\theta)\alpha(\theta,\theta') = \min\{\pi(\theta)q(\theta'\mid\theta),\pi(\theta')q(\theta\mid\theta')\} = \pi(\theta')q(\theta\mid\theta')\alpha(\theta',\theta). $$

Here \(q\) is the proposal density and \(\alpha\) is the acceptance probability. Symmetry gives \(q(\theta'\mid\theta)=q(\theta\mid\theta')\), so the displayed equality follows directly from the Metropolis-Hastings rule. This equality is the detailed-balance condition and implies that \(\pi\) is stationary for the transition. It does not establish that a particular finite chain has explored the posterior adequately.

A practical tuning run therefore separates two questions: does the chosen proposal produce useful movement, and does the resulting chain explore the relevant posterior region? Acceptance rates address the first question only indirectly. Trace plots and effective sample sizes (ESS) provide additional evidence about movement and autocorrelation, but none is a standalone proof of convergence.

Scale, Shape, and Starting Choices

For a one-parameter chain, the proposal standard deviation determines the step size. For several parameters, a covariance matrix controls both the relative step sizes and the directions of proposed movement. If the parameters have different units or orders of magnitude, tuning on raw scales can be inefficient. Sampling transformed or standardized parameters can make a single scale factor more interpretable. For example, positive rate constants are often represented on a log scale; bounded parameters may be represented on an appropriate unconstrained scale. The posterior density on the sampled scale must be the correct transformed density, including any required Jacobian.

A useful multivariate starting form is \(\Sigma_q=c^2S\), where \(S\) describes relative scales and correlations, and \(c\) is an overall multiplier. One may begin with a diagonal \(S\) based on plausible parameter scales, or estimate \(S\) from a pilot run. A common reference for a roughly Gaussian, high-dimensional target is \(c=2.38/\sqrt{d}\), with \(d\) the dimension, when \(S\) approximates the target covariance. This is an asymptotic benchmark under restrictive assumptions, not a universal optimum for nonlinear QSP posteriors. Neither that value nor any single acceptance-rate target replaces diagnostics.

Worked Example: Reducing an Overly Large Scalar Step

Suppose a hypothetical calibration samples the log of a target internalization rate, so the sampled parameter is \(z=\log(k_{\mathrm{int}})\). A Gaussian random-walk proposal with standard deviation \(0.80\) produces 31 accepted transitions in 400 attempts. The trace has long flat stretches interrupted by occasional large jumps.

The observed acceptance rate is \(31/400=0.0775\), or \(7.75\%\). With such a low rate and visibly long repeated stretches, a plausible diagnosis is that the proposal is too large for much of the posterior region. A tuning trial could reduce its standard deviation by half, from \(0.80\) to \(0.40\) log units. The proposal variance changes from \(0.80^2=0.640\) to \(0.40^2=0.160\) squared log units.

That change is a reasoned trial, not a guarantee: the acceptance rate after rescaling must be measured in a new run. A higher acceptance rate alone would not establish improvement; the trace should also show more movement across the posterior range, and the ESS should be considered. Because the proposal is on the log scale, a step of \(0.40\) corresponds to a multiplicative change of \(\exp(0.40)\approx1.49\) in the rate constant before the acceptance decision.

Using Correlation in the Proposal

An isotropic proposal uses \(\Sigma_q=c^2I\), where \(I\) is the identity matrix. It proposes equally scaled changes in every coordinate, which can be inefficient if parameter scales differ. A diagonal proposal permits different marginal step sizes but still proposes changes without accounting for posterior correlation. A covariance-aware proposal can orient steps along correlated directions. Its covariance must remain positive definite so it defines a valid non-degenerate Gaussian proposal.

Pilot estimates can be noisy, especially when the chain has not explored the posterior, when parameters are weakly identified, or when the dimension is large relative to the number of pilot draws. A small ridge term can stabilize an estimated covariance: use \(S_\lambda=S+\lambda I\) for a positive \(\lambda\) chosen relative to the scale of \(S\). Check that the resulting matrix is positive definite and that its implied proposal scales are plausible. Do not assume a covariance estimated from a short, sticky trace is a reliable description of posterior geometry.

Worked Example: Constructing a Covariance-Aware Proposal

Suppose a hypothetical pilot run for three standardized mechanistic parameters suggests the covariance estimate \(S=\begin{pmatrix}1&0.6&0\\0.6&1&0\\0&0&1\end{pmatrix}\). Use the high-dimensional reference multiplier \(c=2.38/\sqrt{3}\) to form a starting proposal covariance \(c^2S\).

First, \(c=2.38/1.732\approx1.374\), so \(c^2\approx1.888\). Therefore,

$$ \Sigma_q=c^2S \approx \begin{pmatrix} 1.888&1.133&0\\ 1.133&1.888&0\\ 0&0&1.888 \end{pmatrix}. $$

The marginal proposal standard deviation for each standardized coordinate is \(\sqrt{1.888}\approx1.374\). The proposal correlation between the first two coordinates remains \(1.133/1.888=0.600\). Thus the proposal allows coordinated movement in the direction indicated by their pilot association, rather than treating those two coordinates as unrelated. This calculation gives a candidate to assess, not a claim that the pilot estimate is accurate or that the reference multiplier is optimal for this posterior.

Read Acceptance Rates Alongside Traces and ESS

A trace plot displays sampled values in iteration order. A trace that barely moves can indicate overly small steps, overly large steps with frequent rejection, or a chain trapped in only one part of a complicated target. A trace that moves rapidly but repeatedly revisits a narrow range may still be highly autocorrelated. Inspect traces for the parameters that matter, and compare their ranges and movement across chains when multiple chains are available. A visually reassuring trace does not by itself establish convergence.

The effective sample size expresses the approximate information in an autocorrelated chain as the equivalent number of independent draws for estimating a mean. For a stationary chain of length \(N\), a basic expression is \(N_{\mathrm{eff}}\approx N/\tau\), where \(\tau=1+2\sum_{k=1}^{\infty}\rho_k\) and \(\rho_k\) is the lag-\(k\) autocorrelation. In practice, software estimates and truncates this sum because only a finite chain is available. ESS is parameter-specific: a proposal may work reasonably for one parameter and poorly for another.

Worked Example: Comparing Three Proposal Settings

In a hypothetical calibration, three fixed proposal settings each generate \(N=2{,}000\) post-warmup draws for a log-transformed biomarker turnover parameter. For illustration, suppose the estimated sums of positive-lag autocorrelations are 24.5, 4.5, and 9.5 for settings A, B, and C. Their acceptance rates are 4%, 24%, and 62%, respectively.

Using \(\tau\approx1+2\sum_{k\geq1}\rho_k\), setting A has \(\tau\approx1+2(24.5)=50\), giving \(N_{\mathrm{eff}}\approx2{,}000/50=40\). Setting B has \(\tau\approx1+2(4.5)=10\), giving \(N_{\mathrm{eff}}\approx200\). Setting C has \(\tau\approx1+2(9.5)=20\), giving \(N_{\mathrm{eff}}\approx100\).

Here B has the largest estimated ESS among the three settings and a moderate acceptance rate. A combines low acceptance with strongly autocorrelated output. C accepts most proposals but has lower ESS than B, illustrating why acceptance alone is not the objective. These estimates are approximate and would need to be assessed for each important parameter; the calculation does not show that any chain has explored all relevant posterior regions.

A Practical Tuning Workflow and Its Limits

1
Choose the sampling scale.
Use parameterizations and units that make proposal scales interpretable, and ensure the target density is correct on that scale.
2
Set a conservative initial proposal.
Start with plausible marginal scales. Use a pilot covariance only if the pilot has made meaningful exploration and the estimate is numerically stable.
3
Run a tuning phase.
Record acceptance by parameter or proposal configuration, inspect traces, and estimate ESS for parameters relevant to calibration conclusions.
4
Adjust and reassess.
Reduce scales when proposals are mostly rejected and traces stick; increase scales when movement is tiny and autocorrelation is high despite near-universal acceptance. Recheck traces and ESS after each meaningful change.
5
Freeze the proposal for production sampling.
Unless a formally justified adaptive method is being used, stop tuning before collecting the draws used for posterior summaries. Retain the tuning record and evaluate the production chains independently.

Tuning choices have limitations. A single overall scale can fail when parameter scales differ greatly. A diagonal covariance cannot align proposals with strong posterior dependence. A full covariance can be unstable if estimated from inadequate pilot output, and even a well-chosen covariance does not solve separated modes or other difficult posterior geometry. If low acceptance persists after sensible rescaling, check the likelihood calculation, parameter transformations, numerical ODE solver behaviour, and whether the chain is proposing outside the meaningful support. If traces remain sticky or ESS remains low, report that limitation rather than treating a preferred acceptance rate as evidence of adequate sampling.

During an adaptive tuning phase, proposal changes depend on the chain history. Arbitrarily continuing such adaptation during production can invalidate the usual fixed-kernel justification. A simple and transparent approach is to adapt during warmup and then hold the proposal fixed. More elaborate adaptive algorithms require conditions that are not supplied merely by observing a desirable acceptance rate.

Common Mistake

Pitfall: “The acceptance rate is close to 25%, so the chain must have converged.” This reasoning is wrong because acceptance rate describes how often proposals are accepted, not whether the chain has visited all important posterior regions or produced low-autocorrelation estimates. A chain can have a seemingly reasonable acceptance rate while remaining trapped or mixing poorly for particular parameters. Check traces and parameter-specific ESS as well, and assess whether the chain has explored the relevant posterior range.

The main practical comparison is between proposal simplicity and its ability to reflect the target’s scales and shape. Isotropic proposals are easiest to set up but can waste computation when scales differ. Diagonal proposals address unequal scales but not correlation. Covariance-aware proposals can improve movement along correlated directions but depend on a credible, stable covariance estimate. These are alternatives within random-walk Metropolis; none removes the need for diagnostics or guarantees adequate exploration.

Check Your Understanding

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

  1. A chain accepts 18 proposals out of 300 attempts. What is its acceptance rate, and what does that number not establish?
  2. A proposal standard deviation is increased from 0.3 to 0.6 on a log-parameter scale. By what factor does its variance change?
  3. Why can a proposal with a high acceptance rate still produce a low ESS?
  4. In a two-parameter calibration, the posterior parameters are strongly correlated. Which is more likely to account for this: an isotropic proposal, a diagonal proposal, or a covariance-aware proposal? State one limitation.
  5. During a tuning phase the proposal is repeatedly adjusted in response to trace plots. What should ordinarily be done before collecting production draws for posterior summaries?

Solutions. (1) The rate is \(18/300=0.060\), or 6%. It does not establish convergence or adequate exploration. (2) The variance changes from \(0.3^2=0.09\) to \(0.6^2=0.36\), a factor of \(0.36/0.09=4\). (3) Accepted steps can be very small or highly correlated, so successive draws may contain little new information. (4) A covariance-aware proposal can align changes with posterior correlation; its covariance estimate may be unreliable if the pilot is short or poorly mixed. (5) Stop adapting and hold the proposal fixed for production sampling, unless using a formally justified adaptive method.

Clinical Biostats