'The Anscombe residuals for the Tweedie family
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
When :math:`p = 3`, then
.. math::
resid\_anscombe_i = \log(Y_i / \mu_i) / \sqrt{\mu_i * scale}
Otherwise,
.. math::
c = (3 - p) / 3
.. math::
resid\_anscombe_i = (1 / c) * (Y_i^c - \mu_i^c) / \mu_i^{p / 6}
/ \sqrt{scale}'

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

    if (self.var_power == 3):
        return (np.log((endog / mu)) / np.sqrt((mu * scale)))
    else:
        c = ((3.0 - self.var_power) / 3.0)
        return ((((1.0 / c) * ((endog ** c) - (mu ** c))) / (mu ** (self.var_power / 6.0))) / (scale ** 0.5))
