[R-sig-Geo] problem simulating random point patterns

Dale Steele dale.w.steele at gmail.com
Wed Oct 10 03:16:05 CEST 2007


I'm trying to reproduce a randomization test for complete spatial
randomness (described in Manly, 2007 Randomization, Bootstrap and
Monte Carlo Methods in Biology). As a first step, I am generating
random point processes in a rectangle.  I can reproduce results in the
book when I generate data as follows:

# (1)
nsim <- 999
xmin <- 0; xmax <- 40
ymin <- 0; ymax <- 50
npoints <- 22
xpoly <- c(0,40,40,0)
ypoly <- c(0,0,50,50)
poly <- as.points(xpoly, ypoly)

# generate an array of nsim random spatial point patterns, each with npoints
rpoints <- array(NA, dim=c(npoints,2,nsim))
  for (i in 1:nsim) {
  rpoints[ , ,i] <- cbind(runif(npoints,min=xmin,
max=xmax),runif(npoints,min=xmin,max=xmax))
}

However, when I use either the csr() function from splancs or
runifpoint from spatstat, the randomization distributions of my
statistic (mean kth nearest neighbor distance) are similar, but do not
reproduce the results of simulations using (1) to simulate the data.

I would expect that (1), (2) and (3) would be identical for a
rectangular sampling area.  Would like to extend to irregular
polygons.  Am I missing something simple here?  Thanks!  --Dale

# (1) generate an array of nsim random spatial point patterns within a
specific polygon area
library(splancs)
rpoints <- array(NA, dim=c(npoints,2,nsim))
  for (i in 1:nsim) {
    rpoints[, ,i] <- csr(poly, npoints)
  }

###  (2) same as above using spatstat runifpoint
library(spatstat)
rpoints <- array(NA, dim=c(npoints,2,nsim))
  for (i in 1:nsim) {
    rpoints[, ,i] <-  runifpoint(npoints,
win=owin(c(xmin,xmax),c(ymin,ymax)), giveup=1000)
  }




More information about the R-sig-Geo mailing list