Error in random labelling using the J function

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in random labelling using the J function

M. Díaz
Hello everyone,

I'm having problems when I run the random labelling using J Function. I'm trying to know if exists spatial co-dependence between two sets of points.  Below I show you the information of my session, the code that I'm using and the error that appears to me.

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] MASS_7.3-51.4       dismo_1.1-4         rgdal_1.4-4
 [4] raster_2.9-22       maptools_0.9-5      sp_1.3-1
 [7] spatstat_1.61-0     rpart_4.1-15        nlme_3.1-140
[10] spatstat.data_1.4-0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1            codetools_0.2-16      lattice_0.20-38
 [4] deldir_0.1-22         grid_3.6.1            tensor_1.5
 [7] goftest_1.1-1         Matrix_1.2-17         spatstat.utils_1.13-0
[10] splines_3.6.1         tools_3.6.1           foreign_0.8-71
[13] polyclip_1.10-0       abind_1.4-5           compiler_3.6.1
[16] mgcv_1.8-28


To establish the relationship between the two sets of points I need to convert the two objects of type ppp to a multitype. What i have done as follows:

studyarea <- readOGR(dsn="studyarea.shp", layer="studyarea")
spts <- readOGR(dsn="sitesv2.shp", layer="sitesv2")
spts1 <- readOGR(dsn="cen_cla.shp", layer="cen_cla")
sta <- as(studyarea,"owin")
p1 <- ppp(x=spts$utmx, y=spts$utmy, window=sta)
p2 <- ppp(x=spts1$utmx, y=spts1$utmy, window=sta)
pm = ppp(c(p1$x, p2$x),c(p1$y,p2$y), window=sta,
         marks=factor(c(rep("A",p1$n),rep("B",p2$n))))

is.multitype(pm)
plot(pm)


Subsequently I have used the following code to check if there is a spatial co-dependence between i (A) and j (B). Or what is the same, between sitesv2 and cen_cla.

Jdif <- function(X, ..., i) {
  Jidot <- Jdot(X, ..., i = i)
  J <- Jest(X, ...)
  dif <- eval.fv(Jidot - J)
  return(dif)
}
E <- envelope(pm, Jdif, nsim = 39, i = "A", j = "B", simulate = expression(rlabel(pm)))


But when I execute E, it shows me the following error:

 Error: in Fest(X, r) the successive r values must be finely spaced: given spacing = 0.010203; required spacing <=  0.00592


And I don't know how I can solve it... At first I thought that the problem could be in the existence of duplicate points, but I eliminated those points and the error continues to appear. I have also updated the Spatstat package to the latest version (1.61-0) but the problem has not been solved either. Therefore I write to you in case anyone knows where the problem may be and how I can solve it.

Thank you so much.


M. D�az



[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>  Libre de virus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

        [[alternative HTML version deleted]]


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error in random labelling using the J function

Adrian Baddeley-3
<[hidden email]> writes:

  > I'm having problems when I run the random labelling using J Function.
> [...]
> library(spatstat)
> [...]
> is.multitype(pm)
> plot(pm)

> Jdif <- function(X, ..., i) {
  >            Jidot <- Jdot(X, ..., i = i)
>              J <- Jest(X, ...)
  >            dif <- eval.fv(Jidot - J)
  >           return(dif)
> }
  > E <- envelope(pm, Jdif, nsim = 39, i = "A", j = "B", simulate = expression(rlabel(pm)))
>  But when I execute E, it shows me the following error:

  > Error: in Fest(X, r) the successive r values must be finely spaced: given spacing = 0.010203; required spacing <=  0.00592

This is a bug in Jdot(). It is not related to the use of random labelling or envelopes.

The bug is fixed in the current development version of spatstat, 1.61-0.042,
which you can install from <https://github.com/spatstat/spatstat>

Note that in the envelope() command above, you don't need the argument 'j="B" and it is ignored.

regards


Prof Adrian Baddeley DSc FAA

John Curtin Distinguished Professor

Department of Mathematics and Statistics

Curtin University, Perth, Western Australia

________________________________


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Error in random labelling using the J function

M. Díaz
I have installed the current development version of spatstat (1.61-0.044) and the code runs correctly without that error appearing. Thank you very much for answering and fixing the bug.

Greetings.

M. D�az.



________________________________
De: R-sig-Geo <[hidden email]> en nombre de Adrian Baddeley <[hidden email]>
Enviado: viernes, 1 de noviembre de 2019 5:16
Para: [hidden email] <[hidden email]>
Asunto: Re: [R-sig-Geo] Error in random labelling using the J function

<[hidden email]> writes:

  > I'm having problems when I run the random labelling using J Function.
> [...]
> library(spatstat)
> [...]
> is.multitype(pm)
> plot(pm)

> Jdif <- function(X, ..., i) {
  >            Jidot <- Jdot(X, ..., i = i)
>              J <- Jest(X, ...)
  >            dif <- eval.fv(Jidot - J)
  >           return(dif)
> }
  > E <- envelope(pm, Jdif, nsim = 39, i = "A", j = "B", simulate = expression(rlabel(pm)))
>  But when I execute E, it shows me the following error:

  > Error: in Fest(X, r) the successive r values must be finely spaced: given spacing = 0.010203; required spacing <=  0.00592

This is a bug in Jdot(). It is not related to the use of random labelling or envelopes.

The bug is fixed in the current development version of spatstat, 1.61-0.042,
which you can install from <https://github.com/spatstat/spatstat>

Note that in the envelope() command above, you don't need the argument 'j="B" and it is ignored.

regards


Prof Adrian Baddeley DSc FAA

John Curtin Distinguished Professor

Department of Mathematics and Statistics

Curtin University, Perth, Western Australia

________________________________


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

        [[alternative HTML version deleted]]


_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo