R: Likelihood Ratio Test and Dean's Tests for Overdispertion
Tests for Overdispertion
R Documentation
Likelihood Ratio Test and Dean's Tests for Overdispertion
Description
When working with count data, the assumption of a Poisson model is
common. However, sometimes the variance of the data is significantly
higher that their mean which means that the assumption of that data have
been drawn from a Poisson distribution is wrong.
In that case is is usually said that data are overdispersed and a better
model must be proposed. A good choice is a Negative Binomial distribution
(see, for example, negative.binomial.
Tests for overdispersion available in this package are the Likelihood Ratio
Test (LRT) and Dean's P_B and P'_B tests.
Alternative hipothesis to be tested. It can be
"less", "greater" or "two.sided", although the usual choice will
often be "greater".
Details
The LRT is computed to compare a fitted Poisson model against a fitted
Negative Binomial model.
Dean's P_B and P'_B tests are score tests. These
two tests were proposed for the case in which we look for overdispersion
of the form
var(Y_i)=μ_i(1+τ μ_i), where
E(Y_i)=μ_i.
See Dean (1992) for more details.
Value
An object of type htest with the results (p-value, etc.).
References
Dean, C.B. (1992), Testing for overdispersion in Poisson and binomial regression models, J. Amer. Statist. Assoc. 87, 451-457.
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(DCluster)
Loading required package: boot
Loading required package: spdep
Loading required package: sp
Loading required package: Matrix
Loading required package: MASS
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DCluster/dean_test.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Tests for Overdispertion
> ### Title: Likelihood Ratio Test and Dean's Tests for Overdispertion
> ### Aliases: test.nb.pois DeanB DeanB2
> ### Keywords: htest
>
> ### ** Examples
>
> library(spdep)
> library(MASS)
>
> data(nc.sids)
>
> sids<-data.frame(Observed=nc.sids$SID74)
> sids<-cbind(sids, Expected=nc.sids$BIR74*sum(nc.sids$SID74)/sum(nc.sids$BIR74))
> sids<-cbind(sids, x=nc.sids$x, y=nc.sids$y)
>
> x.glm<-glm(Observed~1+offset(log(sids$Expected)), data=sids, family=poisson())
> x.nb<-glm.nb(Observed~1+offset(log(Expected)), data=sids)
>
> print(test.nb.pois(x.nb, x.glm))
Likelihood ratio test for overdispersion
data: x.nb : x.glm
LR = 36.421, = 1, p-value = 1.589e-09
sample estimates:
zscore p.mayor.modZ
-6.033594e+00 1.603523e-09
> print(DeanB(x.glm))
Dean's P_B test for overdispersion
data: x.glm
P_B = 7.2275, p-value = 2.459e-13
alternative hypothesis: greater
> print(DeanB2(x.glm))
Dean's P'_B test for overdispersion
data: x.glm
P'_B = 7.3358, p-value = 1.102e-13
alternative hypothesis: greater
>
>
>
>
>
>
> dev.off()
null device
1
>