Last data update: 2014.03.03

R: Compute Whittermore's Statistic
whittermore.statR Documentation

Compute Whittermore's Statistic

Description

Compute Whittermore's statistic. See whittermore manual page for more details.

whittermore.stat computes the test statistic and the test using a hi-square distribution whilst whittermore.test performs a bootstrap test.

Usage

whittermore.stat(data, listw, zero.policy=FALSE)
whittermore.test(formula, data, model, R, ...)

Arguments

formula

Formula that specifies the underlying model. The observed cases are the response and the expected number of cases must be specified as an offset in the log scale (see example below). Note that now it is not necessary to use Observed and Expected and that any other names can be used to specify the observed and expected cases.

model

Parametric model to be used in the bootstrap test. One of "param", "multinom", "poisson" or "negbin". See the DCluster manpage for details.

...

The remaining arguments in 'whittermore.stat' not included in 'whittermore.test'. This is done so because whittermore.test calls whittermore.stat in order to perform the test.

R

Number of replicates used in the test to compute the significance of the observed value of the test statistic.

data

A dataframe containing the data, as specified in the DCluster manpage.

listw

Neighbours list with spatial weights created, for example, by 'nb2listw' (package spdep).

zero.policy

See nb2listw in package spdep.

Value

The value of the statistic.

References

Whittermore, A. S. and Friend, N. and Byron, W. and Brown, J. R. and Holly, E. A. (1987). A test to detect clusters of disease. Biometrika 74, 631-635.

See Also

DCluster, whittermore, whittermore.boot, whittermore.pboot

Examples

library(spdep)
data(nc.sids)
col.W <- nb2listw(ncCR85.nb, zero.policy=TRUE)

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)

#Calculate neighbours based on distance
coords<-as.matrix(sids[,c("x", "y")])

dlist<-dnearneigh(coords, 0, Inf)
dlist<-include.self(dlist)
dlist.d<-nbdists(dlist, coords)

#Calculate weights. They are globally standardised but it doesn't
#change significance.
col.W.whitt<-nb2listw(dlist, glist=dlist.d, style="C")


whittermore.stat(sids, col.W.whitt, zero.policy=TRUE)

whittermore.test(Observed~offset(log(Expected)), sids, model="poisson", R=99, 
   listw=col.W.whitt, zero.policy=TRUE)

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(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/whittermore.stat.Rd_%03d_medium.png", width=480, height=480)
> ### Name: whittermore.stat
> ### Title: Compute Whittermore's Statistic
> ### Aliases: whittermore.stat whittermore.test
> ### Keywords: spatial
> 
> ### ** Examples
> 
> library(spdep)
> data(nc.sids)
> col.W <- nb2listw(ncCR85.nb, zero.policy=TRUE)
> 
> 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)
> 
> #Calculate neighbours based on distance
> coords<-as.matrix(sids[,c("x", "y")])
> 
> dlist<-dnearneigh(coords, 0, Inf)
> dlist<-include.self(dlist)
> dlist.d<-nbdists(dlist, coords)
> 
> #Calculate weights. They are globally standardised but it doesn't
> #change significance.
> col.W.whitt<-nb2listw(dlist, glist=dlist.d, style="C")
> 
> 
> whittermore.stat(sids, col.W.whitt, zero.policy=TRUE)
            [,1]
[1,] 0.007928723
> 
> whittermore.test(Observed~offset(log(Expected)), sids, model="poisson", R=99, 
+    listw=col.W.whitt, zero.policy=TRUE)
Whittermore's test of global clustering 

	Type of boots.: parametric 
	Model used when sampling: Poisson 
	Number of simulations: 99 
	Statistic:  0.007928723 
	p-value :  0.33 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>