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
45
votes
1answer
18k 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 ...
17
votes
1answer
15k 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-...
15
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 ...
5
votes
2answers
16k 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
1answer
3k views

Metropolis-Hastings using log of the density

Does Metropolis-Hastings work with the log of the proposal and the density to be sampled from? That is, say we want to sample from a density $\pi(x)$, using a proposal $q(x|x^{old})$, will the ...
4
votes
1answer
2k views

What is the deeper intuition behind the symmetric proposal distribution in the Metropolis-Hastings Algorithm?

In the Metropolis-Hastings Algorithm, one usually considers a symmetric proposal distribution: $$ J(\theta^*|\theta^{(s)}) $$ where $\theta^*$ is a proposal point and $\theta^{(s)}$ is the accepted ...
2
votes
1answer
225 views

Metropolis Hastings proposal for one parameter restricted to less than the other

Suppose I have parameters $\theta_0$ and $\theta_1$ with prior $$ p(\theta_0,\theta_1)=p(\theta_0|\theta_0<\theta_1)p(\theta_1),$$ that is, $\theta_0$ is less than $\theta_1$. The distributions ...
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 $...
14
votes
1answer
12k 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-...
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 ...
8
votes
4answers
7k 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 ...
13
votes
2answers
1k 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 ...
4
votes
1answer
3k views

MCMC Metropolis-Hastings' jumping distribution for non-negative parameters

The Metropolis-Hastings algorithm is Markov Chain Monte Carlo technique for sampling from some distribution $f(x)$ by constructing a Markov Chain whose equilibrium distribution is equal to $f(x)$. ...
4
votes
2answers
942 views

Questions about acceptance rule of Metropolis algorithm

I have a question concerning about one step in the Metropolis algorithm. The algorithm proceeds as following, Generate a proposed new sample value from the jumping distribution $Q(x'|x_t)$ Calculate ...
2
votes
1answer
526 views

Simplex Random Walk

This link describes how to perform a random walk on the simplex using the Metropolis-Hastings algorithm: http://en.wikipedia.org/wiki/User:Skinnerd/Simplex_Point_Picking The description says: "The ...
1
vote
1answer
894 views

Metropolis-Hastings acceptance ratio for truncated proposal

I have a proposal distribution for one parameter theta_guess theta_guess = guessleft(theta_accept(1,r-1), 0.01,0) which is a ...
26
votes
1answer
16k 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 ...
9
votes
2answers
15k 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 ...
20
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 ...
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 ...
8
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}$ ...
4
votes
2answers
2k views

Approximating 1D integral with Metropolis - Hastings Markov Chain Monte Carlo

I've been asked to approximate the integral of a one dimensional unnormalised posterior with a flat prior, using a Metropolis Hastings Markov Chain Monte Carlo, I realise that this isn't a practical ...
4
votes
3answers
3k views

Metropolis algorithm, what is the target distribution and how to compose it?

When we do Metropolis sampling or MCMC, we need a target distribution $P_{target}(\theta)$, and a proposal distribution $P_{proposal}(\theta)$, then a value $\theta_i$ is generated via $P_{proposal}(\...
7
votes
1answer
930 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 ...
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}$, $...
5
votes
2answers
3k views

Transformation of variables (Metropolis Hastings)

Say I have a bunch of data from a Poisson distribution and I want to find out my posterior i.e. I'm data fitting: $p(\lambda | X) \sim p(X|\lambda)p(\lambda)$ where $p(X|\lambda) = \frac{\exp(-\...
10
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 ...
7
votes
2answers
491 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 ...
5
votes
3answers
4k views

Minimization of a function by Metropolis-Hastings algorithms

When minimizing a function by general Metropolis-Hastings algorithms, the function is viewed as an unnormalized density of some distribution. (1) As density functions are required to be nonnegative, ...
5
votes
2answers
1k views

What is the relationship between Metropolis Hastings and Simulated Annealing?

Context and Problem In the Wikipedia page for Simulated Annealing they state The simulation can be performed either by a solution of kinetic equations for density functions[2][3] or by using the ...
4
votes
1answer
1k views

Gibbs sampling with mixed prior using a Metropolis-Hastings step

My questions are about a sampling procedure for fitting a Bayesian hierarchical model where one of the priors is a mixture distribution of discrete and continuous parts. The model is not my own but I ...
3
votes
2answers
925 views

Likelihood overflow in Metropolis-Hastings acceptance probability

Consider a Bayesian framework where we have priors for some parameters and a likelihood based on the data. Consider the likelihood (and its parametric format) to be very sensitive to the choice of the ...
12
votes
2answers
549 views

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

Island Hopping with Metropolis Algorithm

From John Kruschke's book, Chapter 7, Pg. 120 (summarised for succinctness): A politician is constantly travelling from island to island on a chain of islands... His goal is to visit all the ...
3
votes
1answer
232 views

Expression for the mean acceptance rate of the Metropolis-Hastings algorithm

Let $(E,\mathcal E,\lambda)$ be a measure space $p:E\to[0,\infty)$ be $\mathcal E$-measurable with $$c:=\int p\:{\rm d}\lambda\in(0,\infty)$$ and $$\mu:=\underbrace{\frac1cp}_{=:\:\tilde p}\lambda$$ $...
4
votes
1answer
94 views

Estimate the asymptotic efficiency of a Markov chain sampling by the method of batching

In the paper Efficient Metropolis Jumping Rules, the author is writing that he used "the method of batching" for the estimation of $\operatorname{eff}_{\overline\theta_i}$ in Table 1 (on page 605). ...
4
votes
1answer
390 views

Convergence of Metropolis Hastings with time varying proposal density

Suppose we have a Metropolis-Hastings sampler for a target distribution $f$, and we use a proposal density $Q_t$, that may depend on time $t$. By construction, $f$ is still an invariant density of ...
3
votes
1answer
195 views

How to tune MCMC with unwieldy posterior [duplicate]

Let's say I have $n$ observations of a random variable, $X_1, \dotsm, X_n \sim \mathcal{N}(0, \sigma^2)$. I also assume $\sigma^2$ has a Gamma(1,1) prior distribution, $\pi(x) = \exp(-x)$. I'm now ...
3
votes
1answer
231 views

Decision Rule for Random-Walk Metropolis on Log Scale

I need to sample from a non-standard density which is more tractable on the log-scale. Now I was wondering, how the decision rule is restated: $$ \alpha (x' | x ) = min(1,\frac{\pi(x')}{\pi(x)}) $$ ...
1
vote
1answer
168 views

Are there analytically derivable posteriors that save from doing MCMC other than conjugate priors? [duplicate]

Posteriors for conjugate priors can be analytically derived and save us from doing MCMC. Conjugate priors simply have a posterior in the same family as the prior distribution. Are there other ...
9
votes
2answers
9k 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 ...
7
votes
1answer
159 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$. ...
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 ...
5
votes
1answer
265 views

handling metropolis hastings rejection during a Gibbs sweep

Suppose I have a MCMC involving a 2 step Gibbs sampler. The first part uses metropolis hastings to find the next parameter value. If during one sweep, the result for the first part is a rejections, ...
3
votes
1answer
1k views

Prior selection for Gaussian Processes (GP)

I am trying to select a prior for the covariance parameters of my Gaussian Process (GP) and have been running into numerical problems with my MCMC code. My model is the following: $$Y = D\beta + GP(...
3
votes
1answer
587 views

What is the difference and relationship between posterior distribution function and likelihood function in MCMC?

I am learning MCMC in class, and I encounter one question about the relationship between posterior probability and likelihood function. In our lecture, the professor asked us to take samples from ...
2
votes
1answer
64 views

Unbiased Metropolis-Hastings estimator of the form $\frac{\sum_{i=1}^nW_if(Y_i)}{\sum_{i=1}^nW_i}$. How do we need to choose $W_i$?

Let $(X_n)_{n\in\mathbb N_0}$ be the Markov chain generated by the Metorpolis-Hastings algorithm with proposal kernel $Q$ and target distribution $\mu$ and $(Y_n)_{n\in\mathbb N}$ denote the ...
2
votes
0answers
197 views

Is the Metropolis-Hastings kernel always aperiodic, irreducible and geometrically ergodic?

Let $(E,\mathcal E,\lambda)$ be a measure space, $Q$ be a Markov kernel on $(E,\mathcal E)$ with $$Q(x,B)=\int_B\lambda({\rm d}y)q(x,y)\;\;\;\text{for all }(x,B)\in E\times\mathcal E$$ for some ...
2
votes
0answers
102 views

Can we use of the Metropolis-Hastings importance sampling estimator here?

EDIT: Note that proposing according to $\hat Q$ is equivalent to the following scheme: Given the current state $\tilde x=(i,x')\in\tilde E:=I\times E'$ and $x:=\varphi_i(x')$, sample $j\sim\tilde T(\...
2
votes
1answer
612 views

Sampling on a logarithmic scale

I have to draw samples (variance parameter) based on a Gaussian kernel but on a logarithmic scale. I have no clue how to implement that as a part of the Metropolis-Hastings algorithm. In particular, ...