Questions tagged [metropolis-hastings]

A special type of Markov Chain Monte Carlo (MCMC) algorithm used to simulate from complex probability distributions. It is validated by Markov chain theory and offers a wide range of possible implementations.

The Metropolis-Hastings algorithm is a Markov Chain Monte Carlo (MCMC) technique used to sample from arbitrary probability distributions. The steps of the algorithm to sample from a distribution with density $\mathscr{p}(x)$ are as follows:

  1. Choose an initial point $x_0$ and a proposal distribution $\mathscr{q}(y|z)$. Let $t=0$.
  2. Generate a candidate point $x^\star$ according to the proposal with density $\mathscr{q}(x|x_t)$.
  3. Calculate the value of $$\alpha=\min\left(1,\frac{\mathscr{p}(x^\star)\mathscr{q}(x_t|x^\star)}{\mathscr{p}(x_t)\mathscr{q}(x^*|x_t)}\right)$$
  4. Accept the point $x^\star$ as $x_{t+1}$ with probability $\alpha$ and else set $x_{t+1}=x_t$.
  5. Increment $t$ ($t\rightarrow t+1$) and return to step 2 and iterate until the desired $t_\max$ is reached.

The Metropolis-Hasting algorithm is the generalization of the original or random-walk Metropolis algorithm, for which the proposal density $\mathscr{q}$ must be symmetric, i.e. $\mathscr{q}(y|z)=\mathscr{q}(z|y)$. It is validated by the detailed balance condition, which shows that the Markov chain is both invariant wrt $\mathscr{p}(\cdot)$ and time-reversible.

413 questions
46
votes
1 answer

What is the difference between Metropolis-Hastings, Gibbs, Importance, and Rejection sampling?

I have been trying to learn MCMC methods and have come across Metropolis-Hastings, Gibbs, Importance, and Rejection sampling. While some of these differences are obvious, i.e., how Gibbs is a special case of Metropolis-Hastings when we have the full…
26
votes
1 answer

When would one use Gibbs sampling instead of Metropolis-Hastings?

There are different kinds of MCMC algorithms: Metropolis-Hastings Gibbs Importance/rejection sampling (related). Why would one use Gibbs sampling instead of Metropolis-Hastings? I suspect there are cases when inference is more tractable with…
24
votes
2 answers

Gibbs sampling versus general MH-MCMC

I have just been doing some reading on Gibbs sampling and Metropolis Hastings algorithm and have a couple of questions. As I understand it, in the case of Gibbs sampling, if we have a large multivariate problem, we sample from the conditional…
Luca
  • 4,410
  • 3
  • 30
  • 52
21
votes
1 answer

Can adaptive MCMC be trusted?

I am reading about adaptive MCMC (see e.g., Chapter 4 of the Handbook of Markov Chain Monte Carlo, ed. Brooks et al., 2011; and also Andrieu & Thoms, 2008). The main result of Roberts and Rosenthal (2007) is that if the adaptation scheme satisfies…
20
votes
1 answer

What are some well known improvements over textbook MCMC algorithms that people use for bayesian inference?

When I'm coding a Monte Carlo simulation for some problem, and the model is simple enough, I use a very basic textbook Gibbs sampling. When it's not possible to use Gibbs sampling, I code the textbook Metropolis-Hastings I've learned years ago. The…
19
votes
1 answer

Stan $\hat{R}$ versus Gelman-Rubin $\hat{R}$ definition

I was going through the Stan documentation which can be downloaded from here. I was particularly interested in their implementation of the Gelman-Rubin diagnostic. The original paper Gelman & Rubin (1992) define the the potential scale reduction…
19
votes
4 answers

Metropolis-Hastings algorithms used in practice

I was reading Christian Robert's Blog today and quite liked the new Metropolis-Hastings algorithm he was discussing. It seemed simple and easy to implement. Whenever I code up MCMC, I tend to stick with very basic MH algorithms, such as independent…
csgillespie
  • 11,849
  • 9
  • 56
  • 85
17
votes
2 answers

Confused with MCMC Metropolis-Hastings variations: Random-Walk, Non-Random-Walk, Independent, Metropolis

Over the past few weeks I have been trying to understand MCMC and the Metropolis-Hastings algorithm(s). Every time I think I understand it I realise that I am wrong. Most of the code examples I find on-line implement something that is not consistent…
AstrOne
  • 689
  • 1
  • 6
  • 14
17
votes
1 answer

Understanding Metropolis-Hastings with asymmetric proposal distribution

I have been trying to understand the Metropolis-Hastings algorithm in order to write a code for estimating the parameters of a model (i.e. $f(x)=a*x$). According to bibliography the Metropolis-Hastings algorithm has the following steps: Generate…
AstrOne
  • 689
  • 1
  • 6
  • 14
16
votes
1 answer

Understanding MCMC and the Metropolis-Hastings algorithm

Over the past few days I have been trying to understand how Markov Chain Monte Carlo (MCMC) works. In particular I have been trying to understand and implement the Metropolis-Hastings algorithm. So far I think I have an overall understanding of the…
AstrOne
  • 689
  • 1
  • 6
  • 14
16
votes
1 answer

Metropolis-Hastings integration - why isn't my strategy working?

Assume I have a function $g(x)$ that I want to integrate $$ \int_{-\infty}^\infty g(x) dx.$$ Of course assuming $g(x)$ goes to zero at the endpoints, no blowups, nice function. One way that I've been fiddling with is to use the Metropolis-Hastings…
15
votes
4 answers

Can I change the proposal distribution in random-walk MH MCMC without affecting Markovianity?

Random walk Metropolis-Hasitings with symmetric proposal $q(x|y)= g(|y-x|)$ has the property that the acceptance probability $$P(accept\ y) = \min\{1, f(y)/f(x)\}$$ does not depend on proposal $g(\cdot)$. Does that mean that I can change the…
VitoshKa
  • 302
  • 2
  • 8
14
votes
1 answer

MCMC with Metropolis-Hastings algorithm: Choosing proposal

I need to do a simulation to evaluate an integral of a 3 parameter function, we say $f$, which has a very complicated formula. It is asked to use MCMC method to compute it and implement the Metropolis-Hastings algorithm to generate the values…
Giiovanna
  • 1,108
  • 1
  • 8
  • 21
13
votes
2 answers

For Hamiltonian Monte Carlo, why does negating the momentum variables result in a symmetric proposal?

I have been going through Radford Neal's excellent HMC book chapter in detail. However, there is one detail that I'm really obsessing with now, and I'm not sure if I'm thinking about it right. When describing the Metropolis step for HMC, which is…
12
votes
2 answers

In Bayesian models, can you use Uniform(-inf, inf) as a prior?

In Bayesian models, can you use Uniform(-inf, inf) as a prior? I ask because in an class, we looked at MH MCMC sampler, and showed that to sample from a distribution, we need not explicitly solve for the denominator because the numerator is…
1
2 3
27 28