Tuning and calibration: proposal scales, warmup, chain length, and practical control

NoteWhat you should be able to do after this chapter
  • tune proposal scales in random-walk MCMC deliberately;
  • explain the roles of warmup, chain count, and chain length;
  • interpret adapt_delta, max_treedepth, and initialization in Stan;
  • tune learning rates and schedules in gradient-based optimization;
  • distinguish computational tuning from model specification.

1 Why tuning matters

Every Bayesian algorithm contains control parameters:

  • proposal scales;
  • integration step sizes;
  • number of particles;
  • learning rates;
  • variational family choices;
  • chain lengths and warmup allocations.

These choices do not change the target posterior, but they strongly affect whether the approximation to that target is trustworthy and efficient.

2 Tuning random-walk Metropolis

For proposal

\[ \theta' \sim \mathcal{N}(\theta,\sigma_q^2), \]

the scale \(\sigma_q\) determines the exploration pattern.

2.1 Too small

  • high acceptance;
  • very slow movement;
  • large autocorrelation.

2.2 Too large

  • low acceptance;
  • many rejections;
  • poor exploration.

The right tuning criterion is not acceptance rate in isolation. It is Monte Carlo efficiency, often approximated by ESS per second or similar diagnostics.

3 Chain count, chain length, and warmup

3.1 Chain count

Multiple chains are valuable because they reveal chain-to-chain disagreement and make \(\hat{R}\) meaningful.

3.2 Chain length

Longer chains reduce Monte Carlo error only if the sampler explores the target reasonably well. Very long but highly autocorrelated chains can be less informative than shorter, better-tuned ones.

3.3 Warmup

Warmup serves two roles:

  • move the chain from arbitrary initialization toward typical posterior regions;
  • adapt internal tuning parameters such as step size and mass matrix in HMC.

Warmup is not wasted computation if adaptation is actually learning useful geometry.

4 Stan controls

4.1 adapt_delta

This is the target average acceptance statistic used in HMC adaptation.

  • higher values imply smaller step sizes;
  • smaller step sizes reduce integrator error;
  • computation becomes more expensive.

Increasing adapt_delta is appropriate when modest numerical pathologies remain, but it should not be the first response to severe divergences.

4.2 max_treedepth

This caps the length of NUTS trajectories.

  • if it is too small, exploration can be truncated;
  • if it is repeatedly saturated, the model may be geometrically difficult.

Increasing treedepth can help elongated but otherwise benign geometry. It does not fix fundamentally pathological geometry.

4.3 Initialization

Initialization can affect:

  • early adaptation;
  • numerical stability;
  • convergence speed.

Reasonable initializations matter especially in hierarchical and weakly identified models.

5 Tuning variational methods

Variational approximations introduce their own control parameters:

  • variational family complexity;
  • learning-rate schedule;
  • stochastic-gradient batch size;
  • stopping criteria.

Fast optimization is not enough. One must still ask whether the resulting approximation captures the posterior features that matter for the inferential goal.

6 Tuning optimization in JAX

For gradient-based optimization, the central control parameter is the learning rate \(\eta_t\).

6.1 If \(\eta_t\) is too large

  • updates overshoot;
  • optimization oscillates or diverges.

6.2 If \(\eta_t\) is too small

  • progress is slow;
  • wall-clock efficiency collapses.

Schedules such as step decay, cosine decay, or adaptive methods can help, but they do not eliminate the need to reason about objective curvature.

7 Initialization strategies

Good initial values often come from:

  • prior centers;
  • least-squares or GLM fits;
  • small-variance random perturbations around plausible values;
  • MAP estimates.

Bad initial values can lead to:

  • wasted warmup;
  • numerical overflows in nonlinear models;
  • misleading early diagnostics.

8 Calibration beyond tuning

Tuning asks whether the algorithm is operating efficiently. Calibration asks whether the overall workflow is inferentially valid.

Examples:

  • simulation-based calibration;
  • recovery under synthetic data;
  • comparing exact and approximate inference on benchmark models;
  • prior predictive calibration.

Calibration therefore sits one level above tuning: it checks whether the tuned algorithm and the full workflow behave correctly on known problems.

9 R workflow

The companion tuning lab is mcmc_tuning_grid.R. It runs a random-walk Metropolis sampler across a grid of proposal scales and compares acceptance, autocorrelation, and ESS heuristics.

10 Diagnostics and pitfalls

10.1 Using longer runs to hide poor tuning

This is often inefficient and sometimes misleading.

10.2 Blaming computation for model misspecification

Some “tuning” problems are actually model-design problems.

10.3 Overtuning to one data set

Algorithm settings should generalize to similar problems, not only the current realization.

10.4 Confusing adaptation with inference

Adaptation is part of the computational procedure, not part of the model itself.

11 Exercises

  1. Explain how proposal scale affects acceptance rate and autocorrelation in random-walk Metropolis.
  2. Describe the distinct roles of warmup and post-warmup iterations.
  3. Explain when increasing adapt_delta is reasonable and when it masks geometry problems.
  4. Describe one principled initialization strategy for a hierarchical model.
  5. Explain the difference between tuning an algorithm and calibrating a Bayesian workflow.

12 Summary

Tuning is unavoidable in practical Bayesian computation:

  • algorithms have control parameters;
  • efficiency depends on those parameters;
  • good tuning must be separated from model redesign;
  • calibration asks a broader question than tuning alone.

13 Further reading

Roberts et al. (1997) is the source of the optimal-scaling results that the acceptance-rate rules of thumb come from, including the \(0.234\) asymptotic figure for random-walk Metropolis in high dimensions. Knowing where the number comes from also makes clear how narrow its assumptions are.

Hoffman and Gelman (2014) covers the dual-averaging scheme that adapts HMC’s step size to a target acceptance rate, and Betancourt (2017) explains why raising that target is not a substitute for fixing bad geometry — the theme of the funnel discussion in hierarchical and multilevel models.

Vehtari et al. (2021) is the reference for deciding when a chain has run long enough, and Talts et al. (2018) for checking that a sampler is correct in the first place. Gelman et al. (2020) sets tuning in the context of the wider workflow, where it is usually the last thing to adjust rather than the first.

Back to top

References

Betancourt, Michael. 2017. “A Conceptual Introduction to Hamiltonian Monte Carlo.” arXiv Preprint arXiv:1701.02434.
Gelman, Andrew, Aki Vehtari, Daniel Simpson, et al. 2020. “Bayesian Workflow.” arXiv Preprint arXiv:2011.01808.
Hoffman, Matthew D., and Andrew Gelman. 2014. “The No-u-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo.” Journal of Machine Learning Research 15 (47): 1593–623.
Roberts, Gareth O., Andrew Gelman, and Walter R. Gilks. 1997. “Weak Convergence and Optimal Scaling of Random Walk Metropolis Algorithms.” Annals of Applied Probability 7 (1): 110–20.
Talts, Sean, Michael Betancourt, Daniel Simpson, Aki Vehtari, and Andrew Gelman. 2018. “Validating Bayesian Inference Algorithms with Simulation-Based Calibration.” arXiv Preprint arXiv:1804.06788.
Vehtari, Aki, Andrew Gelman, Daniel Simpson, Bob Carpenter, and Paul-Christian Bürkner. 2021. “Rank-Normalization, Folding, and Localization: An Improved \(\hat{R}\) for Assessing Convergence of MCMC.” Bayesian Analysis 16 (2): 667–718.