5
$\begingroup$

I am implementing an MCMC algorithm in R using the "mvtnorm" package. The data is about 150 dimensions so the likelihood produced by dmvnorm is usually zero (or -inf if "log=TRUE" is set), which make it impossible to compute rejection rate. Could anyone give me some suggestions to handle it? Thanks in advance!

$\endgroup$

1 Answer 1

2
$\begingroup$

I do not understand the issue: when checking dmvnorm, I do get positive values for the density and finite values for the logarithm:

> range(dmvnorm(matrix(rnorm(1e5*150),ncol=150))
[1] 3.299652e-110  1.522980e-78

If you keep getting zero values for your target density in the MCMC steps, it is because you are in the "wrong" region of the space. To avoid being stuck, you can adopt the convention $0/0=1$ in the Metropolis-Hastings acceptance step, which will make the chain move like a random walk until hopefully you get to a region with positive target density.

$\endgroup$
5
  • 1
    $\begingroup$ Thanks! Xi'an. Someone suggest me that I should constrain the shift because maybe it goes too far. Do you have similar experience? $\endgroup$
    – user112758
    Apr 6, 2016 at 12:48
  • $\begingroup$ Absolutely: In the burnin period, the Markov chain behaves like a random walk so it has a positive probability to drift to infinity and possibly never coming back. Any trick that brings your chain to reach a value with positive probability density is acceptable in that the values of the chain before that point are to be thrown out! $\endgroup$
    – Xi'an
    Apr 6, 2016 at 12:56
  • $\begingroup$ Thx! I will try both to see if the code works. $\endgroup$
    – user112758
    Apr 6, 2016 at 13:01
  • $\begingroup$ I know this is super old but it's the only R-specific resource I've found: it does in fact break down for n >= 500, especially when the samples are not from the assumed distribution. Can you point to resources for handling this, or example papers in which people have done so? $\endgroup$ Nov 17, 2020 at 0:35
  • $\begingroup$ I have no idea. $\endgroup$
    – Xi'an
    Nov 17, 2020 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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