statsmodels.genmod.families.family.Gamma.deviance

Gamma.deviance(endog, mu, var_weights=1.0, freq_weights=1.0, scale=1.0)

The deviance function evaluated at (endog, mu, var_weights, freq_weights, scale) for the distribution.

Deviance is usually defined as twice the loglikelihood ratio.

Parameters:
endogarray_like

The endogenous response variable

muarray_like

The inverse of the link function at the linear predicted values.

var_weightsarray_like

1d array of variance (analytic) weights. The default is 1.

freq_weightsarray_like

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

scalefloat, optional

An optional scale argument. The default is 1.

Returns:
Deviancendarray

The value of deviance function defined below.

Notes

Deviance is defined

\[D = 2\sum_i (freq\_weights_i * var\_weights * (llf(endog_i, endog_i) - llf(endog_i, \mu_i)))\]

where y is the endogenous variable. The deviance functions are analytically defined for each family.

Internally, we calculate deviance as:

\[D = \sum_i freq\_weights_i * var\_weights * resid\_dev_i / scale\]