[R-sig-Geo] test for CSR in three dimensions

Adrian Baddeley adrian at maths.uwa.edu.au
Wed Mar 17 03:48:37 CET 2010


Tobias Verbeke writes:

 >  Is there any functionality available to test
 >  CSR for a three-dimensional point pattern ?

In 'spatstat' you can use the functions K3est, G3est, F3est to estimate 
the three-dimensional versions of the K-function, the nearest neighbour 
distance function, and the empty space function. Using simulation 
envelopes, these functions can form the basis of a Monte Carlo test for 
CSR. A realisation of CSR in three dimensions can be simulated using 
'rpoispp3'.

Currently (in spatstat 1.18-0) the envelope command cannot be used 
directly to generate simulation envelopes. However this will be possible 
in the next version 1.18-1.

In spatstat 1.18-1 you will be able to type (if X is a 3D point pattern)
       plot(envelope(X, K3est, nsim=19))
but in spatstat 1.18-0 you would have to use code similar to the 
suggestion of Marcelino de la Cruz as follows below (thanks, Marcelino!)

Adrian Baddeley

=============================================================

n <- nrow(coords(X))
volume <- volume.box3(as.box3(X))
lambda <- n / volume


# observed isotropic  corrected K
kobs <- K3est(X, rmax=1,nrval=101)$iso

#99 simulated CSR patterns

Xsim<- vector("list", 99)
for  (i in 1: 99){
     Xsim[[i]] <- rpoispp3(lambda, domain = as.box3(X))
}

#simulated K functions
   ksim <- sapply(Xsim, function(x) K3est(x, rmax=1,nrval=101)$iso)

# pointwise Monte Carlo test
plot(0:100, kobs, xlab="r", ylab="K3est(r)", type="l")
matplot(0:100,t(apply(ksim,1,range)), lty=2,col=2, type="l", add=T)



More information about the R-sig-Geo mailing list