bn.iscluster: Clustering Function for Besag and Newell's Method

View source: R/besagnewell.stat.R

bn.isclusterR Documentation

Clustering Function for Besag and Newell's Method

Description

This function is used to calculate the significance of the agregation of cases around the current area when scanning the whole area by means of function opgam.

When data sampling distribution is multinomial or poisson the exact p-value is computed. In the other cases (i.e., permutation and negative binomial) it is aproximated by bootstrap.

This function must be passed to function opgam as argument iscluster.

Usage

bn.iscluster(data, idx, idxorder, alpha, k, model="poisson", R=999, mle)

Arguments

data

A dataframe with the data as explained in DCluster.

idx

A boolean vector to know the areas in the current circle.

idxorder

A permutation of the rows of data to order the regions according to their distance to the current centre.

alpha

Test significance.

k

Size of the cluster.

model

Thge model used to generate random observations. It can be 'permutation', 'multinomial', 'poisson' or 'negbin'.

R

Number of bootstrap replicates made to compute pvalue if the local test.

mle

Parameters needed to compute the Negative Binomial distribution (if used). See negbin.sim manual page for details.

Value

A vector of four elements, as described in iscluster manual page.

References

Besag, J. and Newell, J.(1991). The detection of clusters in rare diseases. Journal of the Royal Statistical Society A 154, 143-155.

See Also

DCluster, besagnewell, besagnewell.boot, besagnewell.pboot

Examples

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)

#B&N's method
bnresults<-opgam(data=sids, thegrid=sids[,c("x","y")], alpha=.05, 
	iscluster=bn.iscluster, k=20, R=100, model="poisson", 
	mle=calculate.mle(sids))

#Plot all centroids and significant ones in red
plot(sids$x, sids$y, main="Besag & Newell's method")
points(bnresults$x, bnresults$y, col="red", pch=19)

DCluster documentation built on May 29, 2024, 3:41 a.m.