7.2.3.3.2.7. 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

Returns:

resid_dev : array

Deviance residuals as defined below

Notes

If endog is binary:

resid_dev = sign(endog-mu)*sqrt(-2*log(I_one*mu + I_zero*(1-mu)))

where I_one is an indicator function that evaluates as 1 if endog == 1 and I_zero is an indicator function that evaluates as 1 if endog == 0.

If endog is binomial:

resid_dev = sign(endog - mu) * sqrt(2 * n * (endog * log(endog/mu) +
(1 - endog) * log((1 - endog)/(1 - mu))))

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