[R-sig-Geo] Calculating envelopes for a point pattern on a linear network (equivalent to rshift in 2D)

Rolf Turner r.turner at auckland.ac.nz
Thu Oct 20 01:06:06 CEST 2016


On 19/10/16 02:04, Ignacio Barbeito-Sanchez wrote:

> Dear list members,
>
> We have a bivariate point pattern (two tree species) in a linear
> transect and would like to obtain a null model equivalent to the one
> provided by rshift in 2D to test the independence of both populations
> (in spatstat)
>
> We are using spatstat, but this option does not seem available at the
> moment, or we can't find it (the option available tests the complete
> spatial randomness of one population (p) once the other population is
> fixed (s) but does not keep the pattern of the second population (p)
> unchanged-

I don't understand what you are saying here, not that it matters a great 
deal.

> which is a problem because both populations are clustered in
> our case)
>
> An example of our code follows:
>
> T1 is a point pattern on a linear transect as follows:
>  > T1
> Point pattern on linear network
> 232 points
> Multitype, with possible types: p, s
> Linear network with 2 vertices and 1 line
> Enclosing window: rectangle = [-1, 101] x [-1, 1] units
>
> We used multiple pair correlation functions (linearpfccross)
>
> We computed an envelope to test the hypothesis of complete spatial
> randomness and independance:
> T1.env = envelope.lpp ( T1, fun = linearpcfcross , nsim = 30 , i = "s",
> j = "p")
>
> If anybody has experienced a similar problem or has some hints on how to
> proceed we would be very grateful.

As of present there is no rshift() method for the lpp class in spatstat, 
and it may be a while before such a method is added.  However for the 
simple structure in your example it is not hard to write a little add 
hoc function to do the shifting.  I enclose a skeletal example below.

Note that the characteristics of your example are "hard wired" in the 
given code; it shouldn't to too difficult to make the code more general 
however.  The code does a "loop" type shift, analogous to setting 
edge="torus" in rshift.ppp; this may be inappropriate for clustered 
data.  Again it shouldn't be too difficult to change this behaviour.

Since you did not provide a reproducible example I have tried out my 
code on simplistically simulated data.

=====================================================================
# Code:
X <- psp(0,1,100,1,window=owin(c(0,101),c(-50,50)))
X <- as.linnet(X)
set.seed(42)
X <- runiflpp(232,X)
marks(X) <- factor(sample(c("p","s"),232,TRUE))

foo <- function(r0,X){
    u <- runif(2,-r0/2,r0/2)
    xp <- X$data$x[marks(X)=="p"]+u[1]
    xp[xp < 1] <- xp[xp < 1] + 99
    xp[xp > 100] <- xp[xp > 100] - 99
    xs <- X$data$x[marks(X)=="s"]+u[2]
    xs[xs < 1] <- xs[xs < 1] + 99
    xs[xs > 100] <- xs[xs > 100] - 99
    X$data$x[marks(X)=="p"] <- xp
    X$data$x[marks(X)=="s"] <- xs
    X
}

E <- envelope(X,fun=linearpcfcross,i="s",j="p",
               simulate=expression(foo(15,X)))
plot(E)
=====================================================================

HTH

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-sig-Geo mailing list