<FONT face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=2><div>Dear list, I am comparing two spatial point patterns through the K-function.<br>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).<br><br>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.<br><br>The general idea is:<br>- pts1 are the spatial points from period 1<br>- pts2 are the spatial points from period 2<br>- H0: pts1 and pts2 come from the same population. Consequently I pool pts1 and pts2, and from that I take a subsample.<br>- Then I calculate the K-function for the subsample (K.pooled) and for pts1 (K.p1) and their difference.<br>- I iterate the procedure 1000 times and I get a reference distribution of K.pooled-K.p1<br>- I calculate the K-function for pts2 and the difference K.p2-K.p1<br>- I compare K.p2-K.p1 with the reference ditribution for K.pooled-K.p1 from the bootstrap<br><br>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?<br><br>Thanks in advance for any comment and suggestion.<br>Valerio<br><br>Here, how I coded this idea:<br><br><span style="font-family: Default Monospace,Courier New,Courier,monospace;"># size of the two spatial point patterns</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    size1 <- dim(pts1)[1]</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    size2 <- dim(pts2)[1]</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    </span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;"># set the parameters for the K-function</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    d <- seq(0.5,10,0.2)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;"># calculate K from period 1</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    K.p1 <- khat(pts1, poly=pol, s=d)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    n.iter <- 1000  # number of bootstrap resampling</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    K.mat <- matrix(ncol=length(d), nrow=n.iter)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    for(i in 1:n.iter){</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      samp1 <- sample(1:size1, min(size1,size2), replace=FALSE)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      samp2 <- sample(1:size2, min(size1,size2), replace=FALSE)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      pts.pool <- rbind(pts1[samp1,], pts2[samp2,])</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">        </span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      samp.pool <- sample(1:dim(pts.pool)[1], min(size1,size2), replace=FALSE)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      pts.samp <- pts.pool[samp.pool,]</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">      K.pool <- khat(pts.samp, poly=pol, s=d)</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">     K.mat[i,] <- K.pool-K.p1</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><span style="font-family: Default Monospace,Courier New,Courier,monospace;">    }</span><br style="font-family: Default Monospace,Courier New,Courier,monospace;"><br>-- <br>Valerio Bartolino, PhD<br>Institute of Marine Research<br>Swedish Board of Fisheries<br>PO Box 4, 45321 Lysekil, Sweden<br><br>e-mail: valerio.bartolino@uniroma1.it<br>        valerio.bartolino@gmail.com<br><br>><(((*> ----- ><(((*> ----- ><(((*> ----- ><(((*><br><br></div></FONT>