0
$\begingroup$

I am experimenting with MCMC methods and have implemented a basic Metropolis-Hastings algorithm.

One potential issue with this is that MH posterior samples are autocorrelated. I could verify that mine were as well.

This is often referred to as a known issue and various fixes are suggested such as "thinning" where only every N:th sample is used.

My basic question is: why (or rather when) is this a problem?

In my problem, I just want to get a good posterior distribution of a model parameter, e.g. density and moments.

Even if the samples are autocorrelated, if I have enough of them, shouldn't I be fine?

Let's say that I am not fine (as I am sure someone will explain):

What if I run my chain until it converges, then grab 5000 samples and draw from them in a randomized fashion. Clearly the samples will then not be autocorrelated. Isn't this a better solution than "thinning"?

In my experience when I used thinning I had to basically throw away 20 times the samples I actually used, causing excessive execution time.

Any feedback is welcome.

$\endgroup$
0
$\begingroup$

Even if the samples are autocorrelated, if I have enough of them, shouldn't I be fine?

Yes, but that is the question: How do you know when you have enough of them? There is no exact science to this, but one way is to observe the autocorrelation of the trace and check that it has "converged" to zero

What if I run my chain until it converges, then grab 5000 samples and draw from them in a randomized fashion. Clearly the samples will then not be autocorrelated.

Again, the problem is knowing when the sampler has "converged". When you are learning the posterior distribution, having autocorrelated samples in your trace is not a problem - in fact, samples in the trace are always autocorrelated, and if you want non-correlated samples you can easily achieve this by shuffling them.

To summarise, I think you are slightly misinterpreting the reason why we care about the correlation of samples. If the goal of the MCMC simulation is to generate a trace/s which is representative of the posterior/joint distributions of the system, it doesn't matter if at the the end of the simulation these traces are autocorrelated (we can get around this by shuffling or subsampling them). The main interest in examining the autocorrelations is to understand the trajectory of your simulation and decide whether it has converged in the first place.

Edit

Just to add a minor comment, I personally never thin my samples unless I'm worried about memory. You can keep all your samples, and then at the end of your simulation:

  1. Decide how many samples you want to retain to accurately describe your system
  2. Randomly subsample this many samples, thereby eliminating any concerns of autocorrelation in your final trace
$\endgroup$
  • 1
    $\begingroup$ Thanks. You are right that I did not think this was about convergence. $\endgroup$ – UmaN Aug 13 at 7:42
0
$\begingroup$

My basic question is: why (or rather when) is this a problem?

In short, the autocorrelation will impact the effective sample size, which then effects the precision of estimators. I would recommend you read some of this case study from Michael Betancourt. His case studies are incredibly thorough.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.