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. The default is 1.

Returns:

resid_dev : array

The array of deviance residuals

Notes

resid\_dev_i = sign(Y_i-\mu_i) * \sqrt{piecewise_i}

where piecewise_i is defined as

If Y_i = 0:

piecewise_i = 2 * \log(1 + \alpha * \mu_i)/ \alpha

If Y_i > 0:

piecewise_i = 2 * Y_i * \log(Y_i / \mu_i) - (2 / \alpha) *
(1 + \alpha * Y_i) * \log((1 + \alpha * Y_i) / (1 + \alpha * \mu_i))