In the R package AER you will find the function dispersiontest
, which implements a Test for Overdispersion by Cameron & Trivedi (1990).
It follows a simple idea: In a Poisson model, the mean is $E(Y)=\mu$ and the variance is $Var(Y)=\mu$ as well. They are equal. The test simply tests this assumption as a null hypothesis against an alternative where $Var(Y)=\mu + c * f(\mu)$ where the constant $c < 0$ means underdispersion and $c > 0$ means overdispersion. The function $f(.)$ is some monoton function (often linear or quadratic; the former is the default).The resulting test is equivalent to testing $H_0: c=0$ vs. $H_1: c \neq 0$ and the test statistic used is a $t$ statistic which is asymptotically standard normal under the null.
Example:
R> library(AER)
R> data(RecreationDemand)
R> rd <- glm(trips ~ ., data = RecreationDemand, family = poisson)
R> dispersiontest(rd,trafo=1)
Overdispersion test
data: rd
z = 2.4116, p-value = 0.007941
alternative hypothesis: true dispersion is greater than 0
sample estimates:
dispersion
5.5658
Here we clearly see that there is evidence of overdispersion (c is estimated to be 5.57) which speaks quite strongly against the assumption of equidispersion (i.e. c=0).
Note that if you not use trafo=1
, it will actually do a test of $H_0: c^*=1$ vs. $H_1: c^* \neq 1$ with $c^*=c+1$ which has of course the same result as the other test apart from the test statistic being shifted by one. The reason for this, though, is that the latter corresponds to the common parametrization in a quasi-Poisson model.