# Appropriate goodness-of-fit test for the negative binomial regression

I have used the following Pearson $$χ2$$ test and the deviance test to assess the negative binomial regression using R as

#########################################

# Pearson's χ2 residuals:
dat.resid <- sum(resid(model, type = "pearson")^2)
dat.resid
model$$df.resid 1 - pchisq(dat.resid, model$$df.resid)

# Deviance (G2) residuals:
model$$deviance model$$df.resid
1-pchisq(model$$deviance, model$$df.resid)


###########################################

Results:

Goodness-of-fit (GOF) results for the negative-binomial(NB) model

Test         Value           df             p-value
Deviance     63.787          58              0.28
Pearson      50.795          58              0.74


However, my collaborator commented that the goodness-of-fit test based on deviance and Pearson residuals is not valid for the negative binomial regression. It made me confused. I appreciate your suggestions! Thanks!

• Your collaborator is correct. Goodness of fit tests are only appropriate for binomial or Poisson glms when the variance is determined as a function a the mean. The negative binomial distribution has two parameters, including a negative binomial dispersion parameter as well as the mean, so the goodness of fit test does not apply. Commented Jan 12, 2021 at 21:34
• @GordonSmyth How can we assess that the negative binomial model fits our data well? Is there any model evaluation measure like R-squared available for the negative binomial? Commented Jan 13, 2021 at 2:56
• @Gordon Smyth: Sounds strange. Do you mean some particular gof test or something else? Commented Jan 13, 2021 at 15:18
• @kjetilbhalvorsen I never noticed such a test. Most literature just compared negative-binomial regression with Poisson based on AIC. I am concerned here that how is it possible to know that our model fits the data well. For instance, if we have R-squared > .90, we feel confident that our model explained most of the variance! Commented Jan 13, 2021 at 16:15
• @kjetilbhalvorsen I am refering to the same gof tests as used by OP. My comment is a standard well known glm result. If there is an unknown parameter in the variance function (as for the NB) then estimating that parameter forces the residual deviance to be roughly equal to the residual df so it becomes useless as a gof test. Commented Jan 14, 2021 at 3:56