[R-sig-Geo] [R-sig-geo] can a (modified) pairdist() output be used as a basis for calculating a pcf

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Mon Aug 29 06:01:31 CEST 2011


Jan Quets <Jan.Quets at ua.ac.be> heeft geschreven:

> suppose that I want to change the pcf function in such a way that it 
> doesn't 'use' the distribution of point-to-point distances,
> but instead 'uses' the distribution of edge-to-edge distances.
>  [ ... ]
> is it possible in spatstat to [... ] calculate the (modified)-pcf 
> in an easy way by use of some specific spatstat functions?

      Yes. 
	As a temporary measure, you could use the (currently undocumented)
      function 'compilepcf'. 
	You need something like the following invocation:

           f <- compilepcf(D, r=handle.r.b.args(window=W))

      where D is the pairwise distance matrix, and W is the window containing the
      data. The result is an 'fv' class object. You may have to rescale it 
      using eval.fv. 

      Of course you'll need to think carefully about what this calculation means,
      in order to decide how to rescale it, etc. 

      For the usual pair correlation function, you would have to subsequently 
      divide f(r) by 2 * pi * r. This normalisation is not carried out by 'compilepcf'.

      This will not work in spatstat 2 where we will have a different mechanism that 
      is faster. 

> to calculate a square matrix of edge-to-edge distances (E2E):
> for (i in 1:100){
> for (j in 1:100){
>  sumradii[i,j] = vmrad$marks[i] + vmrad$marks[j]
> }
> }
> E2E = pairdist(vmrad) - sumradii

      You can do this faster using

        sumradii <- outer(marks(vmrad), marks(vmrad), "+")

      You will also need to reset the diagonal of 'E2E' to infinity so that it 
      is not used:

         diag(E2E) <- Inf

Adrian Baddeley



More information about the R-sig-Geo mailing list