Negative binomial observations naturally appears in many biological applications, such as in genomics. This article describes the details of the likelihood-ratio test to determine if two sets of observations come from the same negative binomial distribution or not. Given probability of failure and number of failures , the negative binomial distribution if expressed as
where denotes the number of success.
For likelihood-ratio test one needs to find the maximum likelihood solution of and . Given samples , is found as On the other hand, does not have a closed form solution, and it is found iteratively by solving the following equation
where is the digamma function.
However, this approach problematic when the observations are only slightly over-dispersed, i.e., they resemble Poisson distribution. In this case, , and it becomes hard to find the via optimization. Also since depends on , it approaches to one, and thus, the overall estimation breaks down.
To tackle this issue, a reparameterization of negative binomial distribution is suggested in terms of dispersion parameter and mean . Under this reparameterization the probability distribution of negative binomial is
and the maximum likelihood estimator of is the sample mean, which does not depend on . On the other hand, given , can be found by maximizing the likelihood. Unfortunately, this does not have a closed form solution either. However, one can use iterative method such as Newton’s method to solve this. For Newton’s method the gradient and Hessian can be computed as,
and Newton’s update rule can then be written as
The iteration can be initiated with the moments estimate
Notice that when the observations are underdispersed then this quantity is negative. In such cases, and in situations when the observations are only slightly overdispersed, i.e., this quantity is very close to zero, the estimate of gradient and Hessian might be unstable. Therfore, it is safer to assign to a small value without carrying out the optimization. In this case the distribution will resemble a Poisson distribution.
A Matlab implementation of this test can be found here.
 “Estimating the Negative Binomial Dispersion Parameter“, Mohanad F. Al-Khasawneh, Asian Journal of Mathematics and Statistics 3 (1), 1-15, 2010, ISSN 1994-5418