R: Besag and Newell's Statistic for Spatial Clustering
besagnewell
R Documentation
Besag and Newell's Statistic for Spatial Clustering
Description
Besag & Newell's statistic looks for clusters of size k, i. e., where
the number of observed cases is k. At every area where a case has
appeared, the number of neighbouring regions needed to reach $k$ cases is
calculated. If this number is too small, that is, too many observed cases in
just a few regions with low expected cases, then it is marked as a cluster.
References
Besag, J. and Newell, J.(1991). The detection of clusters in rare diseases.
Journal of the Royal Statistical Society A 154, 143-155.
#B&N must use the centroids as grid.
#The size of teh cluster is 20.
#100 bootstrap simulations are performed
#Poisson is the model used in the bootstrap simulations to generate the
#observations.
#Signifiance level is 0'05, even though multiple tests are made.
library(boot)
library(spdep)
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)
bnresults<-opgam(sids, thegrid=sids[,c("x","y")], alpha=.05,
iscluster=bn.iscluster, set.idxorder=TRUE, k=20, model="poisson",
R=100, mle=calculate.mle(sids) )
#Plot all the centroids
plot(sids$x, sids$y)
#Plot signifiant centroids in red
points(bnresults$x, bnresults$y, col="red", pch=19)
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/besagnewell.Rd_%03d_medium.png", width=480, height=480)
> ### Name: besagnewell
> ### Title: Besag and Newell's Statistic for Spatial Clustering
> ### Aliases: besagnewell
> ### Keywords: spatial
>
> ### ** Examples
>
> #B&N must use the centroids as grid.
> #The size of teh cluster is 20.
> #100 bootstrap simulations are performed
> #Poisson is the model used in the bootstrap simulations to generate the
> #observations.
> #Signifiance level is 0'05, even though multiple tests are made.
>
> library(boot)
> library(spdep)
>
> 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)
>
> bnresults<-opgam(sids, thegrid=sids[,c("x","y")], alpha=.05,
+ iscluster=bn.iscluster, set.idxorder=TRUE, k=20, model="poisson",
+ R=100, mle=calculate.mle(sids) )
>
> #Plot all the centroids
> plot(sids$x, sids$y)
>
> #Plot signifiant centroids in red
> points(bnresults$x, bnresults$y, col="red", pch=19)
>
>
>
>
>
> dev.off()
null device
1
>