Solved – Sampling from an Inverse Gamma distribution

distributionsgibbsinverse gamma distributionsampling

I am using Gibbs sampling in the MCMC estimation of a stochastic volatility model. One of the posterior distributions is an Inverse Gamma distribution.
I was struggling with the sampling procedure or to be precise with the link to the Gamma distribution. Is it true that to get $Y \sim IG(alpha,beta)$, I have to sample $X \sim Gamma(\alpha,1/\beta)$ and take $ Y = 1/X$? This is also inline with posts on mathworks.

However, I also read it up on wolfram and in my opinion they contradict themselves in the article (https://reference.wolfram.com/language/ref/InverseGammaDistribution.html).

From the paragraph Background&Context (which deals with the generalized gamma distribution though):
From the paragraph *Background&Context*

vs. the description from Details (specifically the fourth point):

enter image description here

Does this discrepancy arise due to the difference between the inverse gamma and the generalized inverse gamma?

Best Answer

This discrepancy arises because there are two different parameterizations of the Gamma distribution and each relate differently to the Inverse Gamma distribution.

On Wikipedia, the two parameterizations for the Gamma distribution are differentiated by using $(k,\theta)$ and $(\alpha, \beta)$. $$\text{If } X \sim \text{Gamma}(k, \theta) , \,\,\,\, f(x) = \dfrac{1}{\Gamma(k) \theta^k} x^{k-1} e^{x/\theta}\,.$$ $$\text{If } X \sim \text{Gamma}(\alpha, \beta) , \,\,\,\, f(x) = \dfrac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha-1} e^{x\beta}\,.$$

Here $\alpha$ and $k$ are exactly the same in the pdfs but $\theta$ is and $\beta$ are different. $\theta$ is called the scale parameter and $\beta$ is called the rate parameter. The relation between these two is that $\beta = 1/\theta$.

If $X \sim \text{Gamma}(\alpha, \beta)$ where $\beta$ is the rate parameter, then $1/X \sim IG(\alpha, \beta)$.

If $X \sim \text{Gamma}(k, \theta)$, where $\theta$ is the scale parameter, then $1/X \sim IG(k, 1/\theta)$.

In both those cases, the pdf of the IG is the same. If $Y \sim IG(\alpha, \beta)$, then the pdf of $Y$ is always $$f(y) = \dfrac{\beta^{\alpha}}{\Gamma(\alpha)} x^{-\alpha-1} e^{-\beta/x}.$$

Related Question