statsmodels.genmod.families.family.Binomial.resid_dev

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

Binomial deviance residuals

Parameters:

endog : array-like

Endogenous response variable

mu : array-like

Fitted mean response variable

scale : float, optional

An optional argument to divide the residuals by scale. The default is 1.

Returns:

resid_dev : array

Deviance residuals as defined below

Notes

If the endogenous variable is binary:

resid\_dev_i = sign(Y_i - \mu_i) * \sqrt{-2 *
               \log(I_{1,i} * \mu_i + I_{0,i} * (1 - \mu_i))}

where I_{1,i} is an indicator function that evalueates to 1 if Y_i = 1. and I_{0,i} is an indicator function that evaluates to 1 if Y_i = 0.

If the endogenous variable is binomial:

resid\_dev_i = sign(Y_i - \mu_i) \sqrt{2 * n_i *
               (Y_i * \log(Y_i / \mu_i) + (1 - Y_i) *
               \log(1 - Y_i)/(1 - \mu_i))}

where Y_i and n are as defined in Binomial.initialize.