1
$\begingroup$

I am performing regression analysis in R on count data which are negative binomial distributed. I would like to use a quantile-quantile plot as a tool to diagnose the fit of my models, but I am struggling to find an appropriate method for my data. A Normal Q-Q plot would not be appropriate since the residuals are not expected to be Normally distributed, so I think I need to compare my residuals against theoretical quantiles from the negative binomial distribution. I have tried using the 'qqPlot' function from the 'car' package, but I can't seem to get it to work properly.

$\endgroup$
1
  • 1
    $\begingroup$ What are your residuals? Usually such a model concerns the conditional expectation of the response distribution. If you are, say, subtracting that from the observations, then you won't have anything remotely like a negative binomial distribution--you will have plenty of negative values. If you are using deviance residuals, they won't even be integral and again cannot possibly have a negative binomial distribution. $\endgroup$
    – whuber
    Commented Aug 10, 2022 at 14:57

2 Answers 2

6
$\begingroup$

Normally distributed residuals can be generated using the randomized quantile residual method. For example

library(MASS)
fit <- glm(Days ~ .^4, family = negative.binomial(2), data = quine)
library(statmod)
res <- qresid(fit)
qqnorm(res)
qqline(res)

Here the MASS package provides the negative.binomial GLM family and the quine data example, while the qresid function is part of the statmod package.

$\endgroup$
0
0
$\begingroup$

The package performance has this and other features for negative binomial regressions.

https://easystats.github.io/performance/

By using check_model() with the model, you will have several outputs that may help you understand the performance of your model.

Also, recently discovered DHARMa package, which uses a simulation-based approach to produce residuals plots. It works with complexed models (hierarchichal or mixed models) but, can also lead with negative-binomial ones. Take a look: https://cran.r-project.org/web/packages/DHARMa/vignettes/DHARMa.html

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.