statsmodels.genmod.families.family.NegativeBinomial.resid_anscombe

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

The Anscombe residuals

Parameters:
  • endog (array) – The endogenous response variable
  • mu (array) – The inverse of the link function at the linear predicted values.
  • var_weights (array-like) – 1d array of variance (analytic) weights. The default is 1.
  • scale (float, optional) – An optional argument to divide the residuals by sqrt(scale). The default is 1.
Returns:

resid_anscombe – The Anscombe residuals as defined below.

Return type:

array

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(Y(i2/3)H2F1(αYi)μ(i2/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)