R in Action (Kabacoff, 2011) suggests the following routine to test for overdispersion in a logistic regression:

Fit logistic regression using binomial distribution:

model_binom <- glm(Species=="versicolor" ~ Sepal.Width,
                   family=binomial(), data=iris)

Fit logistic regression using quasibinomial distribution:

model_overdispersed <- glm(Species=="versicolor" ~ Sepal.Width, 
                           family=quasibinomial(), data=iris)

Use chi-squared to test for overdispersion:

pchisq(summary(model_overdispersed)$dispersion * model_binom$df.residual, 
       model_binom$df.residual, lower = F)
# [1] 0.7949171

Could somebody explain how and why the chi-squared distribution is being used to test for overdispersion here? The p-value is 0.79 - how does this show that overdispersion is not a problem in the binomial distribution model?

  • 2
    $\begingroup$ It is pretty hard to not fit the Bernoulli distribution unless you have correlated observations. What about the fit do you suspect is inadequate? $\endgroup$ – Frank Harrell Mar 24 '14 at 3:26
  • $\begingroup$ By correlated observations do you mean that each Bernoulli trial is not independent? $\endgroup$ – luciano Mar 26 '14 at 19:23
  • 1
    $\begingroup$ Yes, e.g. serial or within-cluster correlation; non-independent trials. $\endgroup$ – Frank Harrell Mar 26 '14 at 20:19

The approach described requires unnecessary computations. The test statistic is just

sum(residuals(model_binom, type = "deviance")^2)

This is exactly equal to the Pearson $\chi^2$ test statistic for lack of fit, hence it have chi-squared distribution.

Overdispersion as such doesn't apply to Bernoulli data. Large value of $\chi^2$ could indicate lack of covariates or powers, or interactions terms, or data should be grouped. A p-value of 0.79 indicates the test failed to find any problems.

  • 4
    $\begingroup$ Shouldn't the answer above be modified as follows? sum(residuals(model_binom, type = "deviance")^2)/model_binom$df.residual $\endgroup$ – Steve VW Jan 24 '17 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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