How to extract values from the statistics calculated by the linhom function (L-Function for inhomogeneous Spatial point processes)?

Asked

Viewed 138 times

8

I have to analyze the spatial pattern of some cactus distributions in the field, and since they are heterogeneous, I cannot use Ripley’s K-function (and corresponding L-function) for stationary patterns. With the spatstat package, I calculated and plotted the "in-homogeneous" L function. But I would like to get the calculated values, so I can specify in which values exactly the curve shows pattern change.

Here is an example:

m22.X<-c(16809,4705,19772,5294,107,623,17361,19397,2827,3875,17326,12150,9827,11853,8888,10973,2015,3528,3751,3406,3425,276,1693,44,9794,664,701,762,3601,5577,15122,4757,6293,5077,4801,972,5133,6077,4754, 18036,12805,18731,12312,3414,3405,3369,17476,16794,19343,17703, 11834,11913,11931)
m22.Y<-c(15691,5662,15168,2389,16703,15305,15372,19822,8108,17493,10783, 9227,281,8153,11943,14446,18802,15551,17505,15598,18134,15904, 18151,16408,179,17807,17801,17007,19342,16003,124,3041,5605,3107, 3072,3309,5905,5904,7500,12377,8312,14056,8315,15574,15601,18867, 15298,16224,17420,15556,19724,19778,19577)

# cria objeto espacial para spatstat:
loc.m22<-ppp(m22.X,m22.Y,c(0,20000), c(0,20000))

# calcula Linhom(...)
linm22<-Linhom(loc.m22, correction="best")
plot(linm22,lwd=2)

#calcula intervalo de confiança de L:
bootlm22<-lohboot(loc.m22,fun="Linhom",nsim=1000,correction="best",confidence=0.95,type=7)
plot(bootlm22,lwd=2)

So in the graph, you can see that the shaded area of the confidence interval intersects the dotted line (which marks L values for a Poisson distribution) about when r=1,300, but that the full line only intersects roughly at r=2,500. But what are the exact values? I tried the following:

theo.values<-bootlm22$theo
iso.values<-bootlm22$iso
r.values<-bootlm22$r
matriz<-cbind(r.values,theo.values,iso.values)
matriz
#no local da interceptação, o valor de iso(L calculado) == valor de r 
intercept<-matriz[(matriz[,1]==matriz[,3]),]

but it didn’t work. Does anyone have any idea? I’ve already searched the attributes of the linhom function, but I haven’t found a field that matches what I want.

Thank you, Leila

inserir a descrição da imagem aqui

1 answer

6


As you may have seen, you can recover the values of the minimum confidence interval using bootlm22$lo, the estimated value with bootlm22$iso, the theoretical value with bootlm22$theo and the value of r with bootlm22$r. By associating these vectors, we can find the points they meet.

lo <- bootlm22$lo
iso <- bootlm22$iso
theo <- bootlm22$theo
r <- bootlm22$r

Care should be taken that the values between the three values of the axis y are not identical for the same r, even where the intersection occurs. To find the values, we can look for the smallest differences between one vector and the other. First, for the lower confidence interval:

difflothe <- abs(lo - theo)

The lowest values of this vector are those values of lo who are closer to theo:

head(sort(difflothe))
#[1] 0.000000 1.000166 2.015760 2.883821 4.266349 5.499276

Obviously by doing the Sort we lose the relationship with r, but we can look for the three lowest values in difflothe without losing order:

which(difflothe %in% sort(difflothe)[1:10])
#[1]   1   2   5   7   8  11 138 139 140 141

We see that there are values at the beginning of the curve that are not what we are looking for. If we decrease the amount of values of sort:

which(difflothe %in% sort(difflothe)[1:3])
#[1]   1  11 140

Thus, we can ignore 1 and 11, and the value sought is element 140, ie:

v1 <- r[140]

Using the same reasoning for the value iso:

diffisothe <- abs(iso - theo)
which(diffisothe %in% sort(diffisothe)[1:3])
#[1]   1 269 270
v2 <- r[269]

We can see that these are the results that we want to put them on the graph:

abline(v = v1)
abline(v = v2)

inserir a descrição da imagem aqui

The values of r saved in v1 and v2 sane:

> v1
[1] 1357.422
> v2
[1] 2617.188

It is difficult to automate this approach since there is a region at the beginning that should be ignored, but if there is a r minimum this could be corrected.

  • Wow, @Molx! Thanks! You’ve made it so easy! It works perfectly.

  • 2

    @Leila, if Molx’s answer met you, you can accept it by clicking the "ok" button on the left!

  • Thank you, @Carloscinelli

Browser other questions tagged

You are not signed in. Login or sign up in order to post.