# Negative binomial distribution fit

I am trying to fit a negative binomial distribution, in R, to my over dispersed data (out of 20 ,14 samples are 0, and rest are less than 5). The mean is $-0.8$ and the variance is $2.69$.

The problem is if I use the theta.md function, I get theta around $0.5$, and if I use glm.nb, then I get theta as $.25$. Any idea why the difference is so large?

My data are: 4 1 1 6 3 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0

Thanks for the help.

## 1 Answer

?glm.nb says:

...
The object is like the output of glm but contains three additional components, namely theta for the ML estimate of theta ...

while ?theta.md says:

...
theta.md estimates by equating the deviance to the residual degrees of freedom, an analogue of a moment estimator.

So you have two different estimation methods (ML vs 'analogue of a moment estimator') that should be consistent (i.e. should become close in sufficiently large samples) but which you wouldn't expect to be close in small samples, and with so little data I expect their standard errors are huge.

Why would they be the same?

• Thank you Glen_b. I understand the differences and I am aware that they use different methods. I agree that sample set is small too but I wasnt expecting such a huge variance, hence the question. Thank you.
– sam
May 1, 2014 at 14:41
• Also, is there a way to compare which theta value is closer to the population theta . I mean which theta value is more accurate? Thanks.
– sam
May 1, 2014 at 14:50
• If it were possible to tell which particular one was closer for a given sample, you could potentially use that information to improve your better estimate still further. But that's not possible. You can work out which one is closer on average, for example, by simulating samples from a negative binomial, and comparing the two for closeness to the true value you used when you generated it. If one is is always better for any value of $\theta$, it's clearly preferable. Asymptotically, ML estimators are optimal, but in small samples that's not necessarily the case. May 1, 2014 at 16:09
• Appreciate your response Glen. Please correct me if I am wrong, you mean to say , generate negative binomial samples using theta1 and theta2 and compare it with the sample that I used to get the fit and see which theta gives me samples that closely align to the samples I used to fit. How about computing the variance using the 2 theta's and comparing the variance of the sample I used to fit, and whichever is close is a better fit. Is it a valid test?
– sam
May 1, 2014 at 16:22
• No I don't mean that. You are comparing two estimators for a single unknown population parameter. You want to know which estimator is closer on average. For any given population $\theta$, you can simulate samples and compare the two for whatever measure of closeness you like. You then repeat it across a range of values of $\theta$. Presumably you're most interested in performance roughly in the region of your estimated parameter values (give or take a few standard errors), but the question is of more broader interest if you may have other samples and you'd want to compare over more values. May 1, 2014 at 16:35