1
$\begingroup$

I am trying to sample from a posterior distribution using a MCMC algorithm using the Metropolis-Hastings sampler.

How should I deal with the situations where I'm stuck in regions of the posterior with zero probability?

These regions are present because the posterior distribution is truncated and also due to numerical limitations on the computer the likelihood can become zero if you are very far from the mean. That is, say the likelihood is distributed normally; if you are 100 standard deviations away from the mean you get what appears as zero probability to the computer.

What I want to know is how to chose the initial value of the chain in order to be sure that it is contained in the support of the posterior.

$\endgroup$

1 Answer 1

2
$\begingroup$

This is an implementation problem since, theoretically, MCMC has no problem with truncated distributions.

Let $D$ be the support of your posterior. Just define your log-posterior as $-\infty$ if $\theta\not\in D$ and choose a suitable value on $D$ as an initial point.

For example, suppose that $x_1,\dots,x_n \stackrel{ind.}{\sim} \exp(\lambda)$ and that $\lambda\sim Unif(0,10)$. The following code shows how to implement a Metropolis-Hastings for this model using the package 'mcmc'.

library(mcmc)

set.seed(123)
x = rexp(100,1)  # The theoretical value of lambda is 1

# logposterior    
logpost = function(lambda){
if(lambda>0 & lambda <10) return(sum(dexp(x,lambda,log=T)))
else return(-Inf)
}

# Metropolis-Hastings

NS = 55000

out <- metrop(logpost, scale = .5, initial = 1, nbatch = NS)

out$accept

lambdap =   out$batch[ , 1][seq(5000,NS,25)] # posterior simulations after burning and thinning

hist(lambdap)
$\endgroup$
1
  • $\begingroup$ This does not answer the question: “What I want to know is how to chose the initial value of the chain in order to be sure that it is contained in the support of the posterior.” Your answer just says “choose a suitable value on 𝐷 as an initial point” when that’s the question in the first place. $\endgroup$
    – user76284
    Aug 25, 2020 at 4:18

Your Answer

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

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