The confusing gamma parameter

[This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Boris from Ottawa sent me this email about Introducing Monte Carlo Methods with R:

As I went through the exercises and examples, I believe I found a typo in exercise 6.4 on page 176 that is not in the list of typos posted on  your website.  For simulation of Gamma(a,1) random variables with  candidate distribution Gamma([a],b), the optimal choice of b seems to be  a/[a] rather than [a]/a as suggested in the book.  Since the ratio dgamma(x,a,1)/dgamma(x,a,[a]/a) is unbounded, simulations with candidate distribution Gamma([a],[a]/a) yields poor approximation to the target distribution.

The problem with this exercise and the gamma distribution

f(x|a,b)=\dfrac{x^{a-1}e^{-bx}}{b^a\Gamma(a)}

in general is that it can be parameterised in terms of the scale or in terms of the rate, as recognised by the R [d/p/q/r]gamma functions:


GammaDist                package:stats                 R Documentation

The Gamma Distribution

Description:

Density, distribution function, quantile function and random
generation for the Gamma distribution with parameters ‘shape’ and
‘scale’.

Usage:

dgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE)
pgamma(q, shape, rate = 1, scale = 1/rate, lower.tail = TRUE,
log.p = FALSE)
qgamma(p, shape, rate = 1, scale = 1/rate, lower.tail = TRUE,
log.p = FALSE)
rgamma(n, shape, rate = 1, scale = 1/rate)

Arguments:

x, q: vector of quantiles.

p: vector of probabilities.

n: number of observations. If ‘length(n) > 1’, the length is
taken to be the number required.

rate: an alternative way to specify the scale.

shape, scale: shape and scale parameters.  Must be positive, ‘scale’
strictly.

Thus, Boris understood b to be the scale parameter, while we meant b to be the rate parameter, meaning we are in fine in agreement about the solution! The deeper question is, why use a duplicated and hence confusing parameterisation?! The reason for doing so is that, while the scale is the natural parameter, the rate has the nicer (Bayesian) property of enjoying a gamma conjugate prior (rather than an inverse gamma conjugate prior). This is why the gamma distribution is implicitly calibrated by the rate, instead of the scale, in most of the Bayesian literature.


Filed under: Books, R, Statistics Tagged: dgamma, Introducing Monte Carlo Methods with R, rate, scale, shape

To leave a comment for the author, please follow the link and comment on their blog: Xi'an's Og » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)