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=1α. Due to the negative value of αY the representation with the hypergeometric function H2F1(x)=hyp2f1(2/3.,1/3.,5/3.,x) is advantageous

resid_anscombei=32(Yi(2/3)H2F1(αYi)μi(2/3)H2F1(αμi))/(μi(1+αμi)scale3)(1/6)(var_weights)

Note that for the (unregularized) Beta function, one has Beta(z,a,b)=za/aH2F1(a,1b,a+1,z)