Last data update: 2014.03.03

R: Generate Bootstrap Replicated of Tango's Statistic
tango.bootR Documentation

Generate Bootstrap Replicated of Tango's Statistic

Description

Generate bootstrap replicated of Tango's statistic for general clustering, by means of function boot from boot library. Notice that these functions should not be used separately but as argument statistic when calling function boot.

tango.boot is used when performing non-parametric bootstrap.

tango.pboot must be used for parametric bootstrap.

Usage

tango.boot(data, i, ...)
tango.pboot(...)

Arguments

data

Dataframe with the data as described in DCluster.

i

Permutation generated by the non-parametric boostrap procedure.

...

Additional arguments passed when performing a bootstrap.

Value

Both functions return the value of the statistic.

References

Tango, Toshiro (1995). A Class of Tests for Detecting 'General' and 'Focused' Clustering of Rare Diseases. Statistics in Medicine 14, 2323-2334.

See Also

DCluster, boot, tango, tango.stat

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)


#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.tango<-nb2listw(dlist, glist=lapply(dlist.d, function(x) {exp(-x)}),
        style="C")
	
niter<-100


#Permutation model
tn.boot<-boot(sids, statistic=tango.boot, R=niter, listw=col.W.tango, 
	zero.policy=TRUE)
plot(tn.boot)#Display results

#Multinomial model
tn.mboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
	ran.gen=multinom.sim,  R=niter, listw=col.W.tango, zero.policy=TRUE)
		
plot(tn.mboot)#Display results

#Poisson model
tn.pboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
	ran.gen=poisson.sim,  R=niter, listw=col.W.tango, zero.policy=TRUE)
		
plot(tn.pboot)#Display results

#Poisson-Gamma model
tn.pgboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
	ran.gen=negbin.sim, R=niter, listw=col.W.tango, zero.policy=TRUE)
plot(tn.pgboot)#Display results

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/tango.boot.Rd_%03d_medium.png", width=480, height=480)
> ### Name: tango.boot
> ### Title: Generate Bootstrap Replicated of Tango's Statistic
> ### Aliases: tango.boot tango.pboot
> ### Keywords: spatial
> 
> ### ** 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)
> 
> 
> #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.tango<-nb2listw(dlist, glist=lapply(dlist.d, function(x) {exp(-x)}),
+         style="C")
> 	
> niter<-100
> 
> 
> #Permutation model
> tn.boot<-boot(sids, statistic=tango.boot, R=niter, listw=col.W.tango, 
+ 	zero.policy=TRUE)
> plot(tn.boot)#Display results
> 
> #Multinomial model
> tn.mboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
+ 	ran.gen=multinom.sim,  R=niter, listw=col.W.tango, zero.policy=TRUE)
> 		
> plot(tn.mboot)#Display results
> 
> #Poisson model
> tn.pboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
+ 	ran.gen=poisson.sim,  R=niter, listw=col.W.tango, zero.policy=TRUE)
> 		
> plot(tn.pboot)#Display results
> 
> #Poisson-Gamma model
> tn.pgboot<-boot(sids, statistic=tango.pboot, sim="parametric", 
+ 	ran.gen=negbin.sim, R=niter, listw=col.W.tango, zero.policy=TRUE)
> plot(tn.pgboot)#Display results
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>