1

The R function below draws random counts from a negative binomial distribution. The n is the number of trips a person made into a forest. The mu is the mean number of birds seen per trip. I understand that size is a dispersion parameter for the negative binomial. So, if 20 trips were taken, a mean of mu = 0.8 birds were seen per trip, and the dispersion parameter = m/(theta-1) then the number of birds seen on each trip is 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0:

set.seed(17)
N <- 20
m <- 0.8
theta <- 22
rnbinom(n = N, mu = m, size = m/(theta-1))
#[1] 0 0 0 0 0 2 0 0 0 0 0 0 1 0 0 0 0 0 0 0

My question is where does the equation m/(theta-1) come from? Where can I read more about it? I have looked at a dozen websites focused on the negative binomial without finding this parameterization. Nor have I found it yet in: 1.) Wikipedia, 2.) the documentation for an R package focused on statistical distributions, 3.) a book on statistical distributions, 4.) the documentation for the R function rnbinom or 5.) any of several journal articles on the negative binomial distribution.

2 Answers2

2

I started writing a comment in an attempt to clarify a jumble of different notations but it rapidly grew overlong. I'll do my best to untangle things a bit, at least.

There's several parameterizations in various places in the literature.

I wanted to use $\theta$ to represent what rnbinom calls size (to match Venables and Ripley and simplify my discussion), but you're using $\theta$ for something else so that's out. Let's call it $\kappa$.

The parameterization used in rnbinom has the density as:

$$f(x;p,\kappa)=\frac{\Gamma(x+\kappa)}{\Gamma(\kappa)\, x!}\, p^\kappa\, (1-p)^x,\: x=0,1,2,...,\: 0<p\leq 1,\,\kappa>0$$

In the documentation of rnbinom, $\kappa$ is called size (n when they write the density). In the Wikipedia page on the negative binomial, it's called $r$ (it uses the same definition up to simply using a different symbol for that parameter).

The parameterization used in MASS (the book and the package that comes with R) is in terms of $\mu= \kappa (1-p)/p$ and $\kappa$ [1] (though they use $\theta$ where I have $\kappa$).:

$$f(x;\mu,\kappa)=\frac{\Gamma(y+\kappa)}{\Gamma(\kappa)\, y!}\, \frac{\kappa^\kappa \mu^y}{(\mu+\kappa)^{y+\kappa}},\: y=0,1,2,...,\: \mu,\kappa>0$$

The (excellent) book by Dunn and Smyth uses a different parameterization again ($\mu$ and $\psi=1/\kappa$).

This $\kappa$ (aka size, $r$) is indeed sometimes called a dispersion parameter by some authors, though it's not a dispersion in the sense of the exponential dispersion family; with fixed $\kappa$ I believe that the GLM's dispersion parameter is $1$.

It is, however, related to the sense in which a negative binomial model might be called overdispersed relative to the Poisson, in that $\kappa\to \infty$ would correspond to the limiting Poisson case and any positive value of $\kappa$ would be overdispersed, with smaller $\kappa$ being overdispersed to a greater extent; since the variance is $\mu+\mu^2/\kappa$.

If you want to have a more natural "overdispersion" parameter, Dunn and Smyth's [2] parameterization in terms of $\psi=1/\kappa$ makes more sense (larger $\psi$ means $Var(Y)/E(Y)$ increases, though the excess is related to $\mu$).


So now we come to the question of what does your $\theta$ represent?

Note that m/size in rnbinom or $\mu/\kappa$ is $\theta-1$ in your question, which in Wikipedia's parameterization is $\frac{1-p}{p} = \frac{1}{p} - 1$. So your $\theta$ appears to be $1/p$ (per both Wikipedia and rnbinom).

Where that parameterization (in terms of your $\theta=p^{-1}$) comes from, I cannot say, unfortunately. Where did you see it?


[1]: Venables and Ripley, (2002), Modern Applied Statistics with S (4th ed) [Sec 7.4]

[2]: Dunn and Smyth, (2018), Generalized Linear Models With Examples in R [Sec 10.5.2]

(Note to self: I should dig out the book by de Jong and Heller and check their parameterization, but if memory serves I think it used essentially the same form as MASS does.)

Glen_b
  • 282,281
  • Thank you. Someone sent the code to me in an email. I can ask him about it next week with a link to this post if nobody here recognizes a source for m/(theta-1) before then. – Mark Miller Oct 08 '22 at 07:12
1

I think I have figured out where the size = m/(theta-1) came from for the negative binomial distribution parameterization in my original post. The size parameter apparently can be estimated using the method-of-moments as:

size <- mean(counts) / (var(counts) / mean(counts) - 1)

when counts come from:

counts <- rnbinom(n = N, mu = m, size = m/(theta-1))

So, theta in this parameterization seems to be defined as:

var(counts) / mean(counts)

where m = mean(counts).

I found the method-of-moments equation for size in notes from one of Ben Bolker's labs at this link:

https://math.mcmaster.ca/~bolker/emdbook/lab6.html