[R-sig-Geo] compilepcf

Adrian.Baddeley at csiro.au Adrian.Baddeley at csiro.au
Thu Nov 17 05:10:55 CET 2011


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

   > How to make pcf and compilepcf do the same job 

This is a query about the package 'spatstat'.

It is a query about an _undocumented, internal_ feature of 'spatstat'. There are no guarantees that this feature will continue.

compilepcf() has an argument 'denom' which is the denominator for the pair correlation estimator. Under normal circumstances with a 2D point pattern, 'denom' should be an estimate of lambda^2 * A where lambda is the point process intensity and A is the area of the window containing the data. So take denom = npoints(X)^2/area.owin(as.owin(X)).

compilepcf() has an argument 'weights' which contains the edge correction weights for the pairwise distances. To get agreement between pcf.ppp() and compilepcf() you would also have to insert the same edge correction weights. In pcf.ppp() these are computed by the (undocumented!) functions edge.Trans and edge.Ripley. So set weights=edge.Trans(X) for example. 

compilepcf() has arguments "..." which are passed to density.default to control the smoothing. In pcf.ppp() the smoothing parameter is (by default) selected by Stoyan's rule of thumb but can be overridden by the argument 'bw'. To get agreement between pcf.ppp() and compilepcf() you would have to specify the same value of 'bw' to both.

compilepcf() uses the Gaussian smoothing kernel by default, while pcf.ppp() uses the Epanechnikov kernel by default. So you'd have to specify kernel="gaussian" in the call to pcf.ppp.

Finally you need to set 'endcorrect=FALSE' in compilepcf() because .... never mind.

Example:

bw <- bw.stoyan(redwood)
f1 <- pcf(redwood, kernel="gaussian", bw=bw)
r <- with(f1, r)
denom <- npoints(redwood)^2/area.owin(as.owin(redwood))
f2 <- compilepcf(D, r=r, 
                 denom=denom, weights=edge.Trans(redwood), bw=bw, 
                 endcorrect=FALSE)
f2 <- with(f2, ./(2 * pi * r))
plot(f1, trans ~ r)
plot(f2, add=TRUE)



============
Prof Adrian Baddeley (UWA/CSIRO)
CSIRO Mathematics, Informatics & Statistics
Leeuwin Centre, 65 Brockway Road, Floreat WA 6014, Australia
Tel: 08 9333 6177 | Fax: 08 9333 6121 | Mob: 0410 447 821
Skype: adrian.baddeley



More information about the R-sig-Geo mailing list