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.

Filter by
Sorted by
Tagged with
42
votes
1answer
17k views

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 ...
23
votes
1answer
14k views

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 ...
21
votes
1answer
1k views

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 ...
21
votes
2answers
10k views

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 ...
20
votes
4answers
2k views

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 ...
20
votes
1answer
669 views

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 ...
17
votes
1answer
14k views

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-...
17
votes
1answer
3k views

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 & ...
16
votes
1answer
2k views

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 ...
15
votes
4answers
3k views

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 $...
15
votes
2answers
7k views

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 ...
14
votes
1answer
11k views

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-...
13
votes
1answer
9k views

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 ...
11
votes
2answers
862 views

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 ...
9
votes
2answers
14k views

Acceptance ratio in Metropolis–Hastings algorithm

In the Metropolis–Hastings algorithm for sampling a target distribution, let: $\pi_{i}$ be the target density at state $i$, $\pi_j$ be the target density at the proposed state $j$, $h_{ij}$ be the ...
9
votes
1answer
6k views

Proposal distribution - Metropolis Hastings MCMC

In Metropolis-Hastings Markov chain Monte Carlo, the proposal distribution can be anything including the Gaussian (according to the Wikipedia). Q: What's the motivation for using anything other than ...
9
votes
1answer
639 views

Understanding the Typical Set for Markov chain Monte Carlo sampling

I started reading "A Conceptual Introduction to Hamiltonian Monte Carlo" today, and I've gotten stuck on understanding Betancourt's explanation of what a "typical set" is. If $q_1, q_2, \ldots, q_n$ ...
9
votes
1answer
1k views

MCMC in a frequentist setting

I have been trying to get a sense of the different problems in frequentist settings where MCMC is used. I am familiar that MCMC (or Monte Carlo) is used in fitting GLMMs and in maybe Monte Carlo EM ...
9
votes
2answers
2k views

Confusion related to Gibbs sampling

I came across this article where it says that in Gibbs sampling every sample is accepted. I am a bit confused. How come if every sample it accepted it converges to a stationary distribution. In ...
9
votes
2answers
1k views

Sampling from bivariate distribution with known density using MCMC

I tried to simulate from a bivariate density $p(x,y)$ using Metropolis algorithms in R and had no luck. The density can be expressed as $p(y|x)p(x)$, where $p(x)$ is Singh-Maddala distribution $p(x)...
9
votes
1answer
131 views

sampling cost of $O(d)$ versus $O(2^d)$

I came across the following simulation problem: given a set $\{\omega_1,\ldots,\omega_d\}$ of known real numbers, a distribution on $\{-1,1\}^d$ is defined by $$\mathbb{P}(X=(x_1,\ldots,x_d))\propto (...
8
votes
2answers
8k views

Acceptance rate for Metropolis-Hastings > 0.5

How come it's possible to get Metropolis-Hastings acceptance rates close to 1 (for example, when exploring a unimodal distribution with a normal proposal distribution with too-small SD), after burn-in ...
8
votes
4answers
6k views

Covariance matrix proposal distribution

In a MCMC implementation of hierarchical models, with normal random effects and a Wishart prior for their covariance matrix, Gibbs sampling is typically used. However, if we change the distribution ...
7
votes
2answers
177 views

Using all Metropolis-Hastings proposals to estimate an integral

Suppose we run the Metropolis-Hastings with target distribution $\mu$ to compute the integral $\int f\:{\rm d}\mu$. Usually, we use the estimator $$A_n:=\frac1n\sum_{i=0}^{n-1}f(X_i).$$ However, ...
7
votes
2answers
889 views

Use of Metropolis & Rejection & Inverse Transform sampling methods

I know that the Inverse Transform method is not always a good option to sample from distributions because it is a analytical method dependent on the shape of the distribution function. For example, ...
7
votes
1answer
3k views

What is a good proposal distribution for Metropolis-Hastings for strictly positive parameters?

In Metropolis-Hastings sampling it is required to have a proposal distribution $g(\theta_{new}|\theta_{old},\lambda)$, where $\theta_{old}$ is the last accepted sample in the chain and $\theta_{new}$ ...
7
votes
2answers
147 views

Metropolis Sampling and invalid states

I have a short question about Monte Carlo integration with Metropolis sampling. I have a continuous state space, but only certain parts of this state space are valid. It is possible that the ...
7
votes
1answer
1k views

When is blocked Metropolis sampling more efficient?

Consider the problem of sampling from $p(\mathbf{x}, \mathbf{y})$ using the Metropolis or Metropolis-Hastings (MH) algorithm. I can either propose samples for $p(\mathbf{x}, \mathbf{y})$ directly, or ...
7
votes
2answers
226 views

Reconciling Langevin MC methods as one-step HMC versus as diffusion or brownian motion

I have a basic understanding of Hamiltonian monte carlo and why it works. I've read that Langevin MC is basically a special case of HMC when you only step the dynamics forward a single timestep before ...
7
votes
1answer
137 views

How can we verify the intuition that in the RW-Metropolis-Hastings algorithm with Gaussian proposal too small and too large variances are bad choices

Let $d\in\mathbb N$ and consider the Random Walk Metropolis-Hastings algorithm with a Gaussian proposal kernel $Q$ such that $Q(x,\;\cdot\;)=\mathcal N_d(x,\sigma^2_dI_d)$ for all $x\in\mathbb R^d$. ...
7
votes
1answer
799 views

Which adaptive Metropolis Hastings algorithm is implemented in R package MHadaptive?

There are multiple versions of adaptive Metropolis Hastings algorithms. One is implemented in the function Metro_Hastings of R ...
7
votes
1answer
139 views

Approximate Metropolis algorithm - does it make sense?

Some time ago Xi'an asked What is the equivalent for cdfs of MCMC for pdfs? The naive answer would be to use "approximate" Metropolis algorithm in form Given $X^{(t)} = x^{(t)}$ 1. generate $Y \...
7
votes
0answers
525 views

Tuning MALA (Metropolis-adjusted Langevin) proposal

I'd like to implement a version of Metropolis-adjusted Langevin sampling, but I'm unsure how to go about tuning the parameters of the proposal density. My understanding is that in MALA, a proposal ...
6
votes
3answers
271 views

Conditional distribution of $\exp(-|x|-|y|-a \cdot |x-y|)$

I am trying to use Gibbs sampling or Metropolis-Hastings to draw samples from the joint distribution$$f(x,y)\propto\exp(-|x|-|y|-a \cdot |x-y|)$$ For this I need the conditional distributions of $x$ ...
6
votes
1answer
302 views

Why periodically skip updating a parameter in MCMC?

I'm looking at the MCMC code of a professor doing Metropolis-Hastings update of $(\theta, \alpha, \beta)$. $\theta$ and $\beta$ are matrices. In his code, 1) He updates $\theta$ twice before ...
6
votes
1answer
1k views

Gibbs sampling from a complex full conditional

I have a sampling question relating to Gibbs sampling of a complicated full conditional. Supposed I have a complicated full conditional that I want a single sample from $p(\theta_i$|$\theta_{-i}$, $...
6
votes
1answer
384 views

Why does Slice sampler use the log of the density?

The Slice sampler1 takes as its argument the log of the density to be sampled from. Why is it doing this? A commenter on this question pointed out that it makes no sense to "sample" from the log of ...
6
votes
2answers
465 views

Bayes Factor approximation

A brute force method to approximate the Bayes Factor (the ratio of the denominators (normalizing constants) in the Bayes formula) is to do the following for the two models of interest: repeat ...
6
votes
1answer
2k views

Metropolis-Within-Gibbs sampling with only marginal distribution known for a subset of variables

Typically in Gibbs sampling we want to sample from a joint distribution $p(X_1, X_2, ..., X_N)$, but because the joint is hard to sample from directly, we instead achieve this by iteratively sampling ...
6
votes
1answer
385 views

MCMC Metropolis Hastings - Normalised distribution

I am reading about MCMC from this PDF Murphy's MCMC (1), on page 4, above equation (21) the author states: "Note that when evaluating α (acceptance probability), we only need to know the target ...
6
votes
1answer
511 views

Do sampling methods (MCMC/SMC) work for combination of continuous and discrete random variables?

Consider a distribution $P = \frac{1}{2}P_1 + \frac{1}{2}P_2$ where $P_1, P_2$ are probability measures on a measurable space $(\mathbb R, \mathcal B)$ such that $P_1: A \to \int_A \mathcal N(x; 0, 1)...
6
votes
1answer
2k views

Mathematical foundation of using MCMC in global optimization

MCMC is commonly used to compute the integral in the form of $$\text{Problem A.}~~\int F(x)\pi(x) $$ where $\pi$ is hidden. In the literature, it is explained why MCMC can handle problem A by ...
6
votes
1answer
1k views

MCMC: examples of when direct sampling is difficult (but Metropolis Hastings is easy)

The Metropolis–Hastings algorithm is a Markov chain Monte Carlo (MCMC) method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult. Would ...
6
votes
1answer
416 views

sampling from an unnormalised distribution

If one has to sample (with replacement) from a population $(x_1,x_2,\ldots)$ with weights $(\omega_1,\omega_2,\ldots)$, possibly infinite (although this is asking too much without further details), a ...
6
votes
1answer
267 views

Variance stabilization “rule” for MCMC jumps…anyone?

I have an implementation of an MCMC algorithm (Metropolis-Hastings and Adaptive Metropolis-Hastings) that I want to modify to suit my needs (it's pyMC, if anyone is interested on the details). My ...
6
votes
0answers
59 views

Keeping track of the variance of a Metropolis-Hastings estimator

Let $(E,\mathcal E,\lambda)$ and $(E',\mathcal E',\lambda')$ be measure spaces, $p,q$ be probability densities on $(E,\mathcal E,\lambda)$, and $\varphi:E'\to E$ be bijective and $(\mathcal E',\...
5
votes
2answers
15k views

How to sample using MCMC from a posterior distribution in general?

Assume one has the posterior distribution of a parameter, $p(\theta|y)$ and what I mean by having it is that for each point of $\theta$, one can use Monte Carlo method+MCMC to calculate the $p(\theta|...
5
votes
2answers
2k views

MCMC chain getting stuck

I am trying to use a Metropolis-within-Gibbs type algorithm to sample $\theta$ and $x$ from the following model. Starting with Bayes theorem I can write: $$ P(\theta, x | y) = \frac{P(y | x, \theta) ...
5
votes
2answers
384 views

Why take the minimum in the acceptance ratio in the Metropolis-Hastings algorithm?

The Metropolis-Hastings ratio is defined as $$ \alpha(x'|x) = \min\left(1, \frac{P(x')g(x|x')}{P(x)g(x'|x)}\right) $$ and the state $x'$ is accepted if $u \leq \alpha(x'|x)$, where $u$ is ...
5
votes
1answer
10k views

Implementing a Metropolis Hastings Algorithm in R

Consider a univariate normal model with mean $µ$ and variance $τ$ . Suppose we use a Beta(2,2) prior for $µ$ (somehow we know µ is between zero and one) and a $log-normal(1,10)$ prior for $τ$ (recall ...

1
2 3 4 5
8