statsmodels.genmod.families.family.NegativeBinomial.resid_anscombe

NegativeBinomial.resid_anscombe(endog, mu, var_weights=1.0, scale=1.0)[source]

The Anscombe residuals

Parameters
endogndarray

The endogenous response variable

mundarray

The inverse of the link function at the linear predicted values.

var_weightsarray_like

1d array of variance (analytic) weights. The default is 1.

scalefloat, optional

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

Returns
resid_anscombendarray

The Anscombe residuals as defined below.

Notes

Anscombe residuals for Negative Binomial are the same as for Binomial upon setting \(n=-\frac{1}{\alpha}\). Due to the negative value of \(-\alpha*Y\) the representation with the hypergeometric function \(H2F1(x) = hyp2f1(2/3.,1/3.,5/3.,x)\) is advantageous

\[resid\_anscombe_i = \frac{3}{2} * (Y_i^(2/3)*H2F1(-\alpha*Y_i) - \mu_i^(2/3)*H2F1(-\alpha*\mu_i)) / (\mu_i * (1+\alpha*\mu_i) * scale^3)^(1/6) * \sqrt(var\_weights)\]

Note that for the (unregularized) Beta function, one has \(Beta(z,a,b) = z^a/a * H2F1(a,1-b,a+1,z)\)