Tests the null hypothesis of equidispersion in Poisson GLMs against
the alternative of overdispersion and/or underdispersion.
Usage
dispersiontest(object, trafo = NULL, alternative = c("greater", "two.sided", "less"))
Arguments
object
a fitted Poisson GLM of class "glm" as fitted
by glm with family poisson.
trafo
a specification of the alternative (see also details),
can be numeric or a (positive) function or NULL (the default).
alternative
a character string specifying the alternative hypothesis:
"greater" corresponds to overdispersion, "less" to
underdispersion and "two.sided" to either one.
Details
The standard Poisson GLM models the (conditional) mean
E[y] = mu which is assumed to be equal to the
variance VAR[y] = mu. dispersiontest
assesses the hypothesis that this assumption holds (equidispersion) against
the alternative that the variance is of the form:
VAR[y] = mu + alpha * trafo(mu).
Overdispersion corresponds to alpha > 0 and underdispersion to
alpha < 0. The coefficient alpha can be estimated
by an auxiliary OLS regression and tested with the corresponding t (or z) statistic
which is asymptotically standard normal under the null hypothesis.
Common specifications of the transformation function trafo are
trafo(mu) = mu^2 or trafo(mu) = mu.
The former corresponds to a negative binomial (NB) model with quadratic variance function
(called NB2 by Cameron and Trivedi, 2005), the latter to a NB model with linear variance
function (called NB1 by Cameron and Trivedi, 2005) or quasi-Poisson model with dispersion
parameter, i.e.,
VAR[y] = (1 + alpha) * mu = dispersion * mu.
By default, for trafo = NULL, the latter dispersion formulation is used in
dispersiontest. Otherwise, if trafo is specified, the test is formulated
in terms of the parameter alpha. The transformation trafo can either
be specified as a function or an integer corresponding to the function function(x) x^trafo,
such that trafo = 1 and trafo = 2 yield the linear and quadratic formulations
respectively.
Value
An object of class "htest".
References
Cameron, A.C. and Trivedi, P.K. (1990). Regression-based Tests for Overdispersion in the Poisson Model.
Journal of Econometrics, 46, 347–364.
Cameron, A.C. and Trivedi, P.K. (1998). Regression Analysis of Count Data.
Cambridge: Cambridge University Press.
Cameron, A.C. and Trivedi, P.K. (2005). Microeconometrics: Methods and Applications.
Cambridge: Cambridge University Press.
See Also
glm, poisson, glm.nb
Examples
data("RecreationDemand")
rd <- glm(trips ~ ., data = RecreationDemand, family = poisson)
## linear specification (in terms of dispersion)
dispersiontest(rd)
## linear specification (in terms of alpha)
dispersiontest(rd, trafo = 1)
## quadratic specification (in terms of alpha)
dispersiontest(rd, trafo = 2)
dispersiontest(rd, trafo = function(x) x^2)
## further examples
data("DoctorVisits")
dv <- glm(visits ~ . + I(age^2), data = DoctorVisits, family = poisson)
dispersiontest(dv)
data("NMES1988")
nmes <- glm(visits ~ health + age + gender + married + income + insurance,
data = NMES1988, family = poisson)
dispersiontest(nmes)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(AER)
Loading required package: car
Loading required package: lmtest
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: survival
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/AER/dispersiontest.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dispersiontest
> ### Title: Dispersion Test
> ### Aliases: dispersiontest
> ### Keywords: htest
>
> ### ** Examples
>
> data("RecreationDemand")
> rd <- glm(trips ~ ., data = RecreationDemand, family = poisson)
>
> ## linear specification (in terms of dispersion)
> dispersiontest(rd)
Overdispersion test
data: rd
z = 2.4116, p-value = 0.007941
alternative hypothesis: true dispersion is greater than 1
sample estimates:
dispersion
6.5658
> ## linear specification (in terms of alpha)
> dispersiontest(rd, trafo = 1)
Overdispersion test
data: rd
z = 2.4116, p-value = 0.007941
alternative hypothesis: true alpha is greater than 0
sample estimates:
alpha
5.5658
> ## quadratic specification (in terms of alpha)
> dispersiontest(rd, trafo = 2)
Overdispersion test
data: rd
z = 2.9381, p-value = 0.001651
alternative hypothesis: true alpha is greater than 0
sample estimates:
alpha
1.316051
> dispersiontest(rd, trafo = function(x) x^2)
Overdispersion test
data: rd
z = 2.9381, p-value = 0.001651
alternative hypothesis: true alpha is greater than 0
sample estimates:
alpha
1.316051
>
> ## further examples
> data("DoctorVisits")
> dv <- glm(visits ~ . + I(age^2), data = DoctorVisits, family = poisson)
> dispersiontest(dv)
Overdispersion test
data: dv
z = 6.5428, p-value = 3.019e-11
alternative hypothesis: true dispersion is greater than 1
sample estimates:
dispersion
1.414427
>
> data("NMES1988")
> nmes <- glm(visits ~ health + age + gender + married + income + insurance,
+ data = NMES1988, family = poisson)
> dispersiontest(nmes)
Overdispersion test
data: nmes
z = 12.39, p-value < 2.2e-16
alternative hypothesis: true dispersion is greater than 1
sample estimates:
dispersion
7.344673
>
>
>
>
>
> dev.off()
null device
1
>