# Questions tagged [markov-chain-montecarlo]

Markov Chain Monte Carlo (MCMC) refers to a class of simulation methods for generating samples from a complex target distribution by generating random numbers from a Markov Chain whose stationary distribution is the target distribution. MCMC methods are typically used when more direct methods for random number generation (e.g. inversion method) are infeasible. The very first MCMC method was the Metropolis (et al.) algorithm, later expanded by Hastings.

1,638 questions
Filter by
Sorted by
Tagged with
188k views

### How would you explain Markov Chain Monte Carlo (MCMC) to a layperson?

Maybe the concept, why it's used, and an example.
17k views

### Variational inference versus MCMC: when to choose one over the other?

I think I get the general idea of both VI and MCMC including the various flavors of MCMC like Gibbs sampling, Metropolis Hastings etc. This paper provides a wonderful exposition of both methods. I ...
• 3,572
24k 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 ...
• 2,405
17k views

### Good sources for learning Markov chain Monte Carlo (MCMC)

Any suggestions for a good source to learn MCMC methods?
18k views

### Why is it necessary to sample from the posterior distribution if we already KNOW the posterior distribution?

My understanding is that when using a Bayesian approach to estimate parameter values: The posterior distribution is the combination of the prior distribution and the likelihood distribution. We ...
• 2,641
25k views

### What is the best method for checking convergence in MCMC?

What is your preferred method of checking for convergence when using Markov chain Monte Carlo for Bayesian inference, and why?
• 8,151
7k views

### Computation of the marginal likelihood from MCMC samples

This is a recurring question (see this post, this post and this post), but I have a different spin. Suppose I have a bunch of samples from a generic MCMC sampler. For each sample $\theta$, I know the ...
• 5,216
23k 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 ...
2k views

### Examples of errors in MCMC algorithms

I'm investigating a method for automatic checking of Markov chain Monte Carlo methods, and I would like some examples of mistakes that can occur when constructing or implementing such algorithms. ...
• 3,506
7k views

### Does the Gibbs Sampling algorithm guarantee detailed balance?

I have it on supreme authority1 that Gibbs Sampling is a special case of the Metropolis-Hastings algorithm for Markov Chain Monte Carlo sampling. The MH algorithm always gives a transition probability ...
• 483
5k views

### Hamiltonian Monte Carlo vs. Sequential Monte Carlo

I am trying to get a feel for the relative merits and drawbacks, as well as different application domains of these two MCMC schemes. When would you use which and why? When might one fail but the ...
• 989
11k views

### Why should we care about rapid mixing in MCMC chains?

When working with Markov chain Monte Carlo to draw inference, we need a chain that mixes rapidly, i.e. moves throughly the support of the posterior distribution rapidly. But I don't understand why we ...
• 507
4k views

### How do ABC and MCMC differ in their applications?

To my understanding Approximate Bayesian Computation (ABC) and Markov Chain Monte Carlo (MCMC) have very similar aims. Below I describe my understanding of these methods and how I perceive the ...
• 5,152
8k views

### What MCMC algorithms/techniques are used for discrete parameters?

I know a fair amount about fitting continuous parameters particularly gradient-based methods, but not much about fitting discrete parameters. What are commonly used MCMC algorithms/techniques for ...
• 4,542
12k 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 ...
• 4,700
8k views

### Can Machine Learning or Deep Learning algorithms be utilised to "improve" the sampling process of a MCMC technique?

Based on the little knowledge that I have on MCMC (Markov chain Monte Carlo) methods, I understand that sampling is a crucial part of the aforementioned technique. The most commonly used sampling ...
• 574
13k views

### C++ libraries for statistical computing

I've got a particular MCMC algorithm which I would like to port to C/C++. Much of the expensive computation is in C already via Cython, but I want to have the whole sampler written in a compiled ...
• 4,890
5k views

### Residual diagnostics in MCMC -based regression models

I've recently embarked on fitting regression mixed models in the Bayesian framework, using a MCMC algorithm (function MCMCglmm in R actually). I believe I have understood how to diagnose convergence ...
• 283
948 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 ...
• 5,216
10k views

### Parameters without defined priors in Stan

I've just started to learn to use Stan and rstan. Unless I've always been confused about how JAGS/BUGS worked, I thought you always had to define a prior ...
• 2,457
5k 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 & ...
• 15.7k
2k views

### When did MCMC become commonplace?

Does anyone know around what year MCMC became commonplace (i.e., a popular method for Bayesian inference)? A link to the number of published MCMC (journal) articles over time would be especially ...
2k 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 ...
8k views

### Posterior distribution and MCMC [duplicate]

I have read something like 6 articles on Markov Chain Monte carlo methods, there are a couple of basic points I can't seem to wrap my head around. How can you "draw samples from the posterior ...
• 671
12k views

### MCMC on a bounded parameter space?

I am trying to apply MCMC on a problem, but my priors(in my case they are $\alpha\in[0,1],\beta\in[0,1]$)) are restricted to an area? Can I use normal MCMC and ignore the samples that fall outside of ...
• 1,615
11k views

### Effective Sample Size for posterior inference from MCMC sampling

When obtaining MCMC samples to make inference on a particular parameter, what are good guides for the minimum number of effective samples that one should aim for? And, does this advice change as the ...
• 3,359
17k 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-...
• 739
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 ...
• 13.1k
2k views

### Are MCMC without memory?

I'm trying to understand what Markov chain Monte Carlo (MCMC) are from the French Wikipedia page. They say "that the Markov chain Monte Carlo methods consist of generating a vector $x_ {i}$ only from ...
2k views

### Why don't we see Copula Models as much as Regression Models?

Is there any reason that don't see Copula Models as much as we see Regression Models (e.g. https://en.wikipedia.org/wiki/Vine_copula, https://en.wikipedia.org/wiki/Copula_(probability_theory)) ? I ...
7k views

### Is there a standard method to deal with label switching problem in MCMC estimation of mixture models?

Label switching (i.e., the posterior distribution is invariant to switching component labels) is a problematic issue when using MCMC to estimate mixture models. Is there a standard (as in widely ...
16k views

### Gelman and Rubin convergence diagnostic, how to generalise to work with vectors?

The Gelman and Rubin diagnostic is used to check the convergence of multiple mcmc chains run in parallel. It compares the within-chain variance to the between-chain variance, the exposition is below: ...
• 285
10k 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 ...
• 739
9k 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 ...
• 739
13k views

### Does standardising independent variables reduce collinearity?

I've come across a very good text on Bayes/MCMC. IT suggests that a standardisation of your independent variables will make an MCMC (Metropolis) algorithm more efficient, but also that it may reduce (...
15k views

### Predictions from BSTS model (in R) are failing completely

After reading this blog post about Bayesian structural time series models, I wanted to look at implementing this in the context of a problem I'd previously used ARIMA for. I have some data with some ...
• 937
2k views

### Good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)?

Are there any good summaries (reviews, books) on various applications of Markov chain Monte Carlo (MCMC)? I've seen Markov Chain Monte Carlo in Practice, but this books seems a bit old. Are there ...
• 653
3k views

### Sampling from an Improper Distribution (using MCMC and otherwise)

My basic question is: how would you sample from an improper distribution? Does it even make sense to sample from an improper distribution? Xi'an's comment here kind of addresses the question, but I ...
• 15.7k
7k views

### What is the correct effective sample size (ESS) calculation?

I wish to compute the effective sample size (ESS) for a posterior sample of size $M$. I have looked at several documentations (e.g. WinBUGS p11; Stan sec 15.4) and several other Stack Exchange ...
• 758
1k views

### Hamiltonian monte carlo

Can someone explain the main idea behind Hamiltonian Monte Carlo methods and in which cases they will yield better results than Markov Chain Monte Carlo methods ?
9k views

### Where do the full conditionals come from in Gibbs sampling?

MCMC algorithms like Metropolis-Hastings and Gibbs sampling are ways of sampling from the joint posterior distributions. I think I understand and can implement metropolis-hasting pretty easily--you ...
• 812
3k views

### Hit and run MCMC

I'm trying to implement the hit and run MCMC algorithm, but I'm having a bit of trouble understanding how to go about it. The general idea, is as follows: To generate a proposal jump in MH, we: ...
2k views

### Hamiltonian Monte Carlo: how to make sense of the Metropolis-Hasting proposal?

I am trying to understand the inner working of Hamiltonian Monte Carlo (HMC), but can't fully understand the part when we replace the deterministic time-integration with a Metropolis-Hasting proposal. ...
• 799
4k views

### Doing MCMC: use jags/stan or implement it myself

I am new to Bayesian Statistics research. I heard from researchers that Bayesian researchers better implement MCMC by themselves rather than using tools like JAGS/Stan. May I ask what is the benefit ...
• 768
2k views

### What is the connection between Markov chain and Markov chain monte carlo

I am trying to understand Markov chains using SAS. I understand that a Markov process is one where the future state depends only on the current state and not on the past state and there is a ...
• 6,605
20k views

### MCMC methods - burning samples?

In MCMC methods, I keep reading about 'burn-in' time or the number of samples to 'burn'. What is this exactly, and why is it needed? Once MCMC stabilizes, does it remain stable? How is the notion of ...
• 19.4k
3k views

### When is MCMC useful?

I am having trouble in understanding in which situation the MCMC approach is actually useful. I am going through a toy example from the Kruschke book "Doing Bayesian Data Analysis: A Tutorial with R ...
• 587
11k views

### Does a MCMC fulfilling detailed balance yields a stationary distribution?

I guess I understand the equation of the detailed balance condition, which states that for transition probability $q$ and stationary distribution $\pi$, a Markov Chain satisfies detailed balance if ...
• 1,247