statsmodels.genmod.families.family.Tweedie.resid_dev

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

Tweedie 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

When p = 1,

resid\_dev_i = \mu

when endog = 0 and

resid\_dev_i = endog * \log(endog / \mu) + (\mu - endog)

otherwise.

When p = 2,

resid\_dev_i =  (endog - \mu) / \mu - \log(endog / \mu)

For all other p,

resid\_dev_i = endog ^{2 - p} / ((1 - p) * (2 - p)) -
               endog * \mu ^{1 - p} / (1 - p) + \mu ^{2 - p} /
               (2 - p)