2

I have been using the spatstat package to determine if a point pattern is clustered, random or regular by comparing it to relative frequency distribution of nearest-neighbor distances generated under complete spatial randomness (CSR). Code is as follows (Y is a ppp object of x,y coordinates):

Y<-rpoint(60, 2, fmax=NULL, win=unit.square(),giveup=1000, verbose=FALSE,
       nsim=1, drop=TRUE)
envelope(Y, Gest, nsim = 999, nrank = 25, global=FALSE, fix.n=TRUE)

However, I just realized that the random points have to be distributed at the intersections of a polygon network within the window; they cannot be compared against complete spatial randomness, since they are restricted to crossings of segments of a polygon network. Is there any way to simulate spatial randomness on a network pattern?

I managed to create random line segments and add points at each crossings:

l<-rpoisline(4, win=owin())
i<-selfcrossing.psp(l)
par(mfrow=c(1,2))
plot(l)
plot(i)

However, I am not sure how to integrate this with the envelope() function. I also need the number of crossing to be constant. So is there anyway to specify the number of crossings in the rpoisline() function?

RFrap
  • 21
  • 2
  • There are two questions here (StackOverflow generally likes to restrict to one question per post), and one of them is very hard. (1) Integrating with the `envelope` function: see the `simulate=` argument of `envelope`. (2) Generating Poisson line processes conditional on a fixed number of crossings; I have no idea, it could be very difficult, probably more on-topic for [CrossValidated](https://stats.stackexchange.com) – Ben Bolker Nov 06 '20 at 21:04
  • For convenience, can you make up a simple `ppp` object for your first example so that the question is entirely reproducible/self-contained? – Ben Bolker Nov 06 '20 at 21:11
  • Thank you for your answer @BenBolker. The `simulate=` argument seems to be doing what I want it to. Only need to find a way to specify the number of crossings/points. Note that the `fix.n=` argument is rejected when using `simulate=` argument. – RFrap Nov 07 '20 at 13:30
  • Could you please explain a bit more of the context of the data generating process. You have a Poisson line process generating infinite straight lines in all of R^2, and then you only see the ones hitting some bounded area (unit square in your example), and you know that there always is the same number of lines crossings inside the unit square? – Ege Rubak Nov 08 '20 at 23:43

0 Answers0