'The Anscombe 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 sqrt(scale).
The default is 1.
Returns
resid_anscombe : array
The Anscombe residuals as defined below.
Notes
.. math::
n^{2/3}*(cox_snell(endog)-cox_snell(mu))
/ (mu*(1-mu/n)*scale^3)^{1/6}
where cox_snell is defined as
cox_snell(x) = betainc(2/3., 2/3., x)*betainc(2/3.,2/3.)
where betainc is the incomplete beta function as defined in scipy,
which uses a regularized version (with the unregularized version, one
would just have :math:`cox_snell(x) = Betainc(2/3., 2/3., x)`).
The name \'cox_snell\' is idiosyncratic and is simply used for
convenience following the approach suggested in Cox and Snell (1968).
Further note that
:math:`cox_snell(x) = \frac{3}{2}*x^{2/3} *
hyp2f1(2/3.,1/3.,5/3.,x)`
where hyp2f1 is the hypergeometric 2f1 function.  The Anscombe
residuals are sometimes defined in the literature using the
hyp2f1 formulation.  Both betainc and hyp2f1 can be found in scipy.
References
Anscombe, FJ. (1953) "Contribution to the discussion of H. Hotelling\'s
paper." Journal of the Royal Statistical Society B. 15, 229-30.
Cox, DR and Snell, EJ. (1968) "A General Definition of Residuals."
Journal of the Royal Statistical Society B. 30, 248-75.'

def resid_anscombe(self, endog, mu, scale=1.0):

    endog = (endog * self.n)
    mu = (mu * self.n)
    cox_snell = (lambda x: (special.betainc((2 / 3.0), (2 / 3.0), x) * special.beta((2 / 3.0), (2 / 3.0))))
    return (((self.n ** (2 / 3.0)) * (cox_snell(((endog * 1.0) / self.n)) - cox_snell(((mu * 1.0) / self.n)))) / (((mu * (1 - ((mu * 1.0) / self.n))) * (scale ** 3)) ** (1 / 6.0)))
