Checking for Spatial Clustering of Points in R

11 years, 5 months ago

(0 comments)

The R script below tests whether a set of points on a plane is significantly clustered (as opposed to randomly distributed or, conversely, equally spaced), using the Clark-Evans R measure. From the R spatstat package manual "[Clark-Evans R] is the ratio of the observed mean nearest neighbour distance in the pattern to that expected for a Poisson point process of the same intensity. A value R>1 suggests ordering, while R<1 suggests clustering."

If you have points on a sphere you'll have to reproject - as far as I can tell there's no way to use spherical distance formulas. You'll also want to use a different measure to check for spatial clustering with respect to an attribute of the data points, for example Getis Ord G.

The spatstat package requires a window (essentially a polygon bounding box, and in this example a shapefile of the contiguous US is used. Because the edges of the data are a coastline (i.e. physically significant rather than an arbitrary data limit), I'm not using the edge-correct R in the results. The test gives a p-value, which tells you how significantly clustered/ordered your data is.

coords97<-read.csv("1997CoCoords.csv")

install.packages("deldir")
install.packages("maptools")
install.packages("spatstat_1.31-1.tar.gz", repos = NULL, type="source")

library(spatstat)
library(maptools)

x<-readShapeSpatial("nos80k.shp")
y<-as(x, "SpatialPolygons")
spatstat.options(checkpolygons=FALSE)
usawin<-as.owin(y)
spatstat.options(checkpolygons=TRUE)

points97<-ppp(coords97[,2],coords97[,3], window=usawin)

ce97<-clarkevans(points97)
ce97test<-clarkevans.test(points97, alternative="clustered")

Comments

  • There are currently no comments

New Comment

required
required (not published)
optional