# Why iterative estimation of dispersion in negative binomial glm

If we do a negative binomial GLM with unknown deviance, a frequent strategy (used for example by glm.nb in package MASS in R) is to use a Gibbs sampler:

1. Hold dispersion fixed, estimate the mean
2. Hold mean fixed, estimate the dispersion

Isn't the mean the same than that would be guessed by Poisson regression? If so, why bother with the Gibbs sampler? Why not just fit the mean using Poisson, then fit the dispersion?

## 1 Answer

It's not the same but it can be close. In this example, offset and exponent are less than $10^{-3}$ apart between the poisson and negative binomial estimate. The Poisson dispersion estimate is 1.08, while the negative binomial is 1.09

R code:

library(ggplot2)
library(data.table)
library(MASS)

data=data.table(x=1:100)
data[,mu:=5*x]
data[,y:=rnbinom(100, mu = mu, size=1)]

lmp=glm(y~log(x),data=data,family=poisson(link="log"))
data[,pred.poisson:=predict(lmp,type="response")]
disp.pois=data[,theta.ml(y,mu,.N)]

lmnb=glm.nb(y~log(x), data=data, link="log")
data[,pred.nb:=predict(lmnb,type="response")]

ggplot(data)+geom_point(aes(x,y))+geom_line(aes(x,mu,colour="true mean"))+
geom_line(aes(x,pred.poisson,colour="poisson"))+
geom_line(aes(x,pred.nb,colour="nb"))

• I fail to understand how this answers the question. Sep 14, 2016 at 9:13
• it's a practical example that final inferences are different but close, what else can I tell you? Feel free to write something better. Sep 14, 2016 at 10:09