'Deviance residuals
Notes
Deviance residuals are defined
.. math:: d_j = \pm\left(2\left[Y_j\ln\left(\frac{Y_j}{M_jp_j}\right) + (M_j - Y_j\ln\left(\frac{M_j-Y_j}{M_j(1-p_j)} \right) \right] \right)^{1/2}
where
:math:`p_j = cdf(X\beta)` and :math:`M_j` is the total number of
observations sharing the covariate pattern :math:`j`.
For now :math:`M_j` is always set to 1.'

@cache_readonly
def resid_dev(self):

    endog = self.model.endog
    M = 1
    p = self.predict()
    res = (((- (1 - endog)) * np.sqrt(((2 * M) * np.abs(np.log((1 - p)))))) + (endog * np.sqrt(((2 * M) * np.abs(np.log(p))))))
    return res
