[R-sig-Geo] compilepcf
Quets Jan
Jan.Quets at ua.ac.be
Wed Nov 16 18:25:41 CET 2011
suppose v is a point pattern;
D = pairdist(v)
f1 = pcf(v)
and
f2 = (compilepcf(D,r=f1$r))/(2*pi*f1$r)
How to make pcf and compilepcf do the same job (or how to make f1$obs and f2$est equal)? f1$obs and f2$est do not only differ by a constant value, so scaling either f1$obs or f2$est with a constant, cannot make these vectors equal.
PS: The purpose is to use compilepcf with another distance matrix, but first I want to check if it works by generating the pcf with compilepcf, and comparing this result with pcf(v)$obs (should be more or less equal)
kind regards,
Jan
________________________________________
Van: Adrian.Baddeley at csiro.au [Adrian.Baddeley at csiro.au]
Verzonden: maandag 29 augustus 2011 6:01
Aan: r-sig-geo at r-project.org
CC: Quets Jan; Adrian.Baddeley at csiro.au; r.turner at auckland.ac.nz
Onderwerp: [R-sig-geo] can a (modified) pairdist() output be used as a basis for calculating a pcf
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