Dear list, I am comparing two spatial point patterns through the K-function.
The library splancs offers the opportunity for calculate the K statistics (function khat) and the std.err for the difference between two K-functions (function secal).

I wrote a small code to assess the significance of the difference between two K-functions through a bootstrap approach. I would like to understand if the resampling strategy I'm using make sense, and if there are alternative more appropriate approaches.

The general idea is:
- pts1 are the spatial points from period 1
- pts2 are the spatial points from period 2
- H0: pts1 and pts2 come from the same population. Consequently I pool pts1 and pts2, and from that I take a subsample.
- Then I calculate the K-function for the subsample (K.pooled) and for pts1 (K.p1) and their difference.
- I iterate the procedure 1000 times and I get a reference distribution of K.pooled-K.p1
- I calculate the K-function for pts2 and the difference K.p2-K.p1
- I compare K.p2-K.p1 with the reference ditribution for K.pooled-K.p1 from the bootstrap

One of the main problem I've found with this scheme is that it is sensible to the different size of the two spatial point patterns pts1 and pts2. For instance if the number of points in pts1 >> pts2 then the pooled dataset will be highly biased toward pts1. What about if at every iteration I sample pts1 (so that pts1 and pts2 have the same size), and then I pool the two datasets? Does it make sense?

Thanks in advance for any comment and suggestion.
Valerio

Here, how I coded this idea:

# size of the two spatial point patterns
    size1 <- dim(pts1)[1]
    size2 <- dim(pts2)[1]
   
# set the parameters for the K-function
    d <- seq(0.5,10,0.2)

# calculate K from period 1
    K.p1 <- khat(pts1, poly=pol, s=d)

    n.iter <- 1000  # number of bootstrap resampling
    K.mat <- matrix(ncol=length(d), nrow=n.iter)

    for(i in 1:n.iter){

      samp1 <- sample(1:size1, min(size1,size2), replace=FALSE)
      samp2 <- sample(1:size2, min(size1,size2), replace=FALSE)

      pts.pool <- rbind(pts1[samp1,], pts2[samp2,])
       
      samp.pool <- sample(1:dim(pts.pool)[1], min(size1,size2), replace=FALSE)
      pts.samp <- pts.pool[samp.pool,]

      K.pool <- khat(pts.samp, poly=pol, s=d)
     K.mat[i,] <- K.pool-K.p1
    }

--
Valerio Bartolino, PhD
Institute of Marine Research
Swedish Board of Fisheries
PO Box 4, 45321 Lysekil, Sweden

e-mail: valerio.bartol...@uniroma1.it
        valerio.bartol...@gmail.com

><(((*> ----- ><(((*> ----- ><(((*> ----- ><(((*>

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to