# Parametrization of Gamma and Negative Binomial in R

I have some Poisson data {${y_1,...,y_n}$} and a Gamma prior, and I wish to construct a predictive posterior distribution.

As I understand, if my Gamma hyperparameters are $\alpha$ (the prior number of occurrences) and $\beta$ (the prior number of observations), the predictive posterior is: ${y\space|\space y_1...y_n,\alpha,\beta}\space\tilde\space NegBin({\sum\limits_{i=1}^n y_i+\alpha}, \frac{1}{1+\beta+n})$

However, because of the multiple parametrizations of both Gamma and negative binomial, my attempts to actually implement this in R were so far futile.

Am I right that in the above formula $\alpha$ is shape and $\beta$ is rate in dgamma()? Am I right then that $\sum\limits_{i=1}^n y_i+\alpha$ is size in dnbinom()? And what is prob then? I thought it was $\frac{1}{1+\beta+n}$, but the resulting distribution doesn't seem to make sense.

• Are you sure the posterior predictive is $NB(\sum_{i=1}^n y_i + \alpha, \frac{1}{n +\beta +1})$? I have just been watching the derivation at youtube.com/watch?v=iCxrimJzzDo In his notation he gets $NB(\sum_{i=1}^n y_i + \alpha, n +\beta)$ In your notation that's $NB(\sum_{i=1}^n y_i + \alpha, \frac{1}{n +\beta})$ Feb 23, 2018 at 16:59

For the 'NegBinomial' distribution in the R stats package ?NegBinomial, the parameter choice is different from the one appearing e.g. in Wikipedia. The R 'prob' parameter is $\text{prob} = 1 - p$ where $p$ is as in Wikipedia's notation and as in your notation. So in your case, use $\text{prob} = 1 - 1 / ( 1 + \beta + n)$ for the predictive distribution. The 'size' parameter is the same in the two notations, and your interpretation of it is good.
• Just to add that you probably meant ?NegBinomial, right? Apr 6, 2014 at 10:38
• I've just realised that prob = 1-1/(1+$\beta$+n) is equivalent to mean $\mu$ = ($\alpha$+s)/($\beta$+n) [since prob=size/(size+$\mu$)], which makes perfect sense. Apr 6, 2014 at 10:54
• And in fact R's NegBinomial functions can be parametrized with mu rather than prob. Apr 6, 2014 at 11:44