statsmodels.genmod.families.family.Tweedie.deviance

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

Returns the value of the deviance function.

Parameters:

endog : array-like

Endogenous response variable

mu : array-like

Fitted mean response variable

freq_weights : array-like

1d array of frequency weights. The default is 1.

scale : float, optional

An optional scale argument. The default is 1.

Returns:

deviance : float

Deviance function as defined below

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)

Once resid\_dev_i is calculated, then calculate deviance as

D = \sum{2 * freq\_weights * resid\_dev_i}