7.2.3.3.6.6. statsmodels.genmod.families.family.NegativeBinomial.resid_dev

NegativeBinomial.resid_dev(endog, mu, scale=1.0)[source]

Negative Binomial Deviance Residual

Parameters:

endog : array-like

endog is the response variable

mu : array-like

mu is the fitted value of the model

scale : float, optional

An optional argument to divide the residuals by scale

Returns:

resid_dev : array

The array of deviance residuals

Notes

resid_dev = sign(endog-mu) * sqrt(piecewise)

where piecewise is defined as

If Yi=0:

piecewisei=2log(1+alphamu)/alpha

If Yi>0:

piecewisei=2Ylog(Y/μ)2/α(1+αY)log((1+αY)/(1+αμ))