statsmodels.genmod.families.family.NegativeBinomial.loglike

NegativeBinomial.loglike(endog, lin_pred=None)[source]

The loglikelihood function for the negative binomial family.

Parameters:

endog : array-like

Endogenous response variable

lin_pred : array-like

The linear predictor of the model. This is dot(exog,params), plus the offset if present.

Returns:

llf : float

The value of the loglikelihood function evaluated at (endog,mu,scale) as defined below.

Notes

sum(endog*log(alpha*exp(lin_pred)/(1+alpha*exp(lin_pred))) -
log(1+alpha*exp(lin_pred))/alpha + constant)

where constant is defined as:

constant = gammaln(endog + 1/alpha) - gammaln(endog + 1) -
           gammaln(1/alpha)