Skip to contents

Compares the observed acceptance rate against the optimal rate for the sampler: 0.234 for random-walk Metropolis, 0.574 for MALA, about 0.8 for HMC. These are not interchangeable, and judging an HMC run by the Metropolis target will send you in the wrong direction.

Usage

morie_acceptance_rate_diagnostic(
  chains,
  target = NULL,
  kind = c("metropolis", "mala", "hmc")
)

Arguments

chains

matrix of draws, one row per chain.

target

optional target rate; defaults by kind.

kind

"metropolis", "mala" or "hmc".

Value

list with acceptance_rate, target, deviation, recommendation, per_chain.

Details

Acceptance rate alone says nothing about mixing. A sampler taking tiny steps accepts almost everything and explores almost nothing – read this with ESS, never on its own.

References

Roberts, G. O., Gelman, A. and Gilks, W. R. (1997). Weak convergence and optimal scaling of random walk Metropolis algorithms. Annals of Applied Probability, 7(1), 110-120.

Examples

set.seed(1)
ch <- matrix(cumsum(rnorm(400) * rbinom(400, 1, 0.3)), nrow = 2)
round(morie_acceptance_rate_diagnostic(ch)$acceptance_rate, 2)
#> [1] 0.5