How to fit a negative binominal model to data using maximum likelihood estimation

914 Views Asked by At

I am trying to fit a negative binominal distribution to a dataset that only has one field and that field is the number of words in a sentence. How do I fit the distribution using statsmodels.discrete.discrete_mode

1

There are 1 best solutions below

0
Betelgeux On

I think that statsmodels class is just meant to be a backend asset for regression models, and not for fitting distributions. See the reference here: Regression with Discrete Dependent Variable

But in an answer in an other question here, there is a link, with a possible workaround to exploit the statsmodels regression model, to fit your distribution: Newbie question about discrete distributions and MLE

I have looked at scipy.stats.nbinom as well for you, as scipy has the MLE fitting methods for all kinds of distributions. But the discrete distributions do not have fitting methods. There are numerous answers here explaining the difficulties with that, and some alternative approaches:

As an alternative possibility besides the ones mentioned in the above answers, I can advise you to check out Bayesian numerical methods with the PyMC3 package, as that includes a Negative Binomial distribution as well.