Re: Gamma distribution & Markov chain Monte Carlo



On Jul 18, 12:47 am, Maniaoh <n.hoai...@xxxxxxxxx> wrote:
Hi Lucas,

Thank you very much. I was able to code it right. Use of normal
distribution sometimes create value < 0 that causes terrible pain. I
also did add a guard to check it and change the way I draw u.

Just to be clear, there's nothing wrong with your Normal proposal
generating values, y, less than zero. The gamma density, gamDist(y,
a, b), should return zero for negative arguments. Since this factor
is in the numerator of the acceptance ratio, alpha becomes zero and
the the negative value will never be accepted.

It sounds like you may have "fixed" your code by preventing the
proposal distribution from proposing negative numbers. If you did this
by adding a loop like

% normal distribution is used as proposal distribution
y = vari(index - 1) + randn(1)*sig;
while y < 0,
y = vari(index - 1) + randn(1)*sig;
end

then you have *changed your proposal distribution* from a Normal to a
truncated Normal distribution and your acceptance ratio calculation is
no longer correct. In fact, you would have to use only Metropolis-
Hastings since this proposal is not symmetric and the Metropolis
algorithm no longer applies.

It's very easy to invalidate a sampling algorithm by making "obvious"
changes.

-Lucas
.



Relevant Pages