statsmodels.genmod.families.family.Family.deviance

method

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

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
Deviancearray

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\]