linearK - large time difference between empirical and acceptance envelopes in spatstat

65 Views Asked by At

I am interested in knowing correlation in points between 0 to 2km on a linear network. I am using the following statement for empirical data, this is solved in 2 minutes.

obs<-linearK(c, r=seq(0,2,by=0.20))

Now I want to check the acceptance of Randomness, so I used envelopes for the same r range.

acceptance_enve<-envelope(c, linearK, nsim=19, fix.n = TRUE, funargs = list(r=seq(0,2,by=0.20)))

But this show estimated time to be little less than 3 hours. I just want to ask if this large time difference is normal. Am I correct in my syntax to the function call of envelope its extra arguments for r as a sequence?

Is there some efficient way to shorten this 3 hour execution time for envelopes?

I have a road network of whole city, so it is quite large and I have checked that there are no disconnected subgraphs.

c    
Point pattern on linear network
    96 points
    Linear network with 13954 vertices and 19421 lines
    Enclosing window: rectangle = [559.653, 575.4999] x 
    [4174.833, 4189.85] Km

thank you.

EDIT AFTER COMMENT

system.time({s <- runiflpp(npoints(c), as.linnet(c)); 
+ linearK(s, r=seq(0,2,by=0.20))})
   user  system elapsed 
343.047 104.428 449.650 

EDIT 2

I made some really small changes by deleting some peripheral network segments that seem to have little or no effect on the overall network. This also lead to split some long segments into smaller segments. But now on the same network with different point pattern, I have even longer estimated time:

> month1envelope=envelope(months[[1]], linearK ,nsim = 39, r=seq(0,2,0.2))
Generating 39 simulations of CSR  ...
1, 2,  [etd 12:03:43] 

The new network is

> months[[1]]
Point pattern on linear network
310 points
Linear network with 13642 vertices and 18392 lines
Enclosing window: rectangle = [560.0924, 575.4999] x [4175.113, 
4189.85] Km

System Config: MacOS 10.9, 2.5Ghz, 16GB, R 3.3.3, RStudio Version 1.0.143

1

There are 1 best solutions below

1
On

You don't need to use funargs in this context. Arguments can be passed directly through the ... argument. So I suggest

acceptance_enve <- envelope(c, linearK, nsim=19, 
                            fix.n = TRUE, r=seq(0,2,by=0.20))

Please try this to see if it accelerates the execution.