There have been a large number of papers on why we should refrain from using the inverse-gamma distribution as the prior for the variance term in linear regression. However, although half-Cauchy is proposed as the default prior, many people seem to rely on the Metropolis-Hastings (MH) algorithm since the full conditional is not a recognizable distribution that we know of. I wanted to show how we can get around this problem and get a much better sampler for the half-Cauchy variance.

The model is very simple.’

We will assign a Gaussian prior for , and a standard half-Cauchy prior for , . Half-Cauchy has a density function of the form . The joint-posterior looks like

Since is not the distribution of interest, I will just skip it. What I want to do here is sample efficiently without relying on MH. I suggest you use the ‘slice sampler’. I don’t want to go deep into what slice sampling is doing theoretically but there is a hand-waving way of determining whether a slice sampler would be available or not. That is, look at the full conditional and get rid of some term. If it is of some standard distribution, then you’re set to go.

Now here is how it works. Let’s pick out terms and form the full conditional of .

If term disappears, it is the kernel of an inverse-gamma distribution. This is where the uniform random variable comes to rescue. Take the nuisance term and set it as the maximum value of the uniform variable. . Of course, this is when is given. Then, the joint full conditional would be

If you integrate out the uniform variable, it will recover the original full conditional. Let’s think reversely this time. If we, say, have the uniform variable given, what will the distribution of the variance be? We should first reverse the constraint so that it is arranged in terms of , which becomes

Therefore, if we know the value of , should be drawn from the truncated inverse gamma distribution!

It is usually more comfortable to sample from the truncated gamma distribution than the inverse gamma distribution so it is better to say

A truncated gamma distribution has a closed-form inverse-cdf so sampling from it is not hard. I would like to attach my matlab code for the sampler but wordpress doesn’t seem to have such a functionality so if anybody needs one, please leave a comment with your email address and I will send you the file.

### Like this:

Like Loading...