5

I'm writing a simple Metropolis-Hastings MCMC algorithm. Every time a move gets accepted, the point is added to a list of accepted points. I wonder what exactly I should do when a proposed move has been rejected.

  • Should the last accepted point be added to the list again, thus making the list one entry longer,

    or

  • should I not add anything to the list, continuing until finally some new point gets accepted?

  • I am aware of this question: http://stats.stackexchange.com/questions/30729/examples-of-errors-in-mcmc-algorithms I quote: **An example of such an error would be failing to output a value when Metropolis-Hastings rejects a proposed move.** Does that mean the last point should be added once again? Thanks! – Michael Langbein Nov 07 '14 at 17:41
  • Wait till you accept. Which is why having a good proposal density is critical. – tchakravarty Nov 07 '14 at 17:41
  • Thanks a lot @fgnu for the **really** quick answer! It makes a lot more sense that way, too; with a bad proposal distribution I would otherwise get a long list of almost always the same point. Merci! – Michael Langbein Nov 07 '14 at 17:52
  • 2
    I am not sure you can wait until you accept one value. In the general algorithm when you reject a move, you have to add to the list the last accepted value. If you propose a move, reject and then propose a new move, in the MH ratio you have to take into account that you reject one move. – niandra82 Nov 07 '14 at 18:07
  • Ah, now this might become an interesting discussion. So you say that I need to adjust the Metropolis ratio every time I reject a move? – Michael Langbein Nov 07 '14 at 18:23
  • 1
    @niandra82 Hmm, I somehow thought the question was about simple AR. In RWMH, what you say is true. Michael, you can see the first example in the [Gamerman & Lopes book, chapter 6](http://www.dme.ufrj.br/mcmc/) for exact code. – tchakravarty Nov 07 '14 at 18:40
  • Look here: http://eco.uninsubria.it/dipeco/Quaderni/files/QF2000_6_.pdf – niandra82 Nov 07 '14 at 18:53
  • @fgnu: I would suggest avoiding the "wait till you accept" sentence as it can be interpreted both ways... – Xi'an Nov 07 '14 at 19:34
  • 2
    The idea in MH is that you either move or you don't. If you accept the new proposal, $x_{t+1}$ takes that value (you 'move' to the new value); otherwise $x_{t+1}=x_t$ (you "don't move" to the proposed value when you don't accept). If you only list the values you accept without keeping track of how many proposals they are retained for, you'll have the wrong probabilities. – Glen_b Nov 08 '14 at 00:23

1 Answers1

7

The validation of the Metropolis-Hastings algorithm relies on repeating the current value in the Markov chain if the proposed value is rejected. You should not consider the list of accepted points as your sample but instead the Markov chain with transition \begin{align*} X_{t+1} &= Y_{t+1} \quad&\text{if } U_{t+1}\le \pi(Y_{t+1})/\pi(X_t)\\ &= X_t \quad&\text{otherwise} \end{align*} (assuming a symmetric proposal distribution). The repetition of the current value in the event of a rejection is what makes the algorithm valid, i.e., why $\pi$ is the stationary distribution.

It is always possible to study the distribution of the accepted and of the rejected values, with some recycling possible by Rao-Blackwellisation, but this study is more advanced and far from necessary to understand the algorithm.

Xi'an
  • 90,397
  • 9
  • 157
  • 575
  • Thank you guys very much! I need a little while to work through the links given in the comments - will mark the answer as accepted by tomorrow! – Michael Langbein Nov 07 '14 at 22:16
  • 2
    Alright, got it now. If the proposal $Y_{t+1}$ has been rejected, I will repeat the last accepted value $X_t$ and add it to my list again. If I didn't, that would lead to a wrong stationary distribution and therefore wrong inferences. Thank you @Xi'an and everyone else, also for the very helpful links! – Michael Langbein Nov 08 '14 at 06:42