[R-sig-Geo] Help with the Kmeasure function from the Spatstat package
adrian at maths.uwa.edu.au
Fri Dec 8 02:59:16 CET 2006
Virgilio Gomez-Rubio writes:
> Diggle (2003), for example, describes what you ask and most of the
> examples in the book can be reproduced using package Splancs. Check
> manual page of function mse2d and references (in Splancs) as well.
I beg to disagree. The function 'Kmeasure' in spatstat does not have
a counterpart in any other R package, to my knowledge.
The function mse2d (splancs) is not appropriate for selecting the
sigma parameter in Kmeasure.
`Kmeasure' calculates an estimate of the `reduced second moment measure'
of a point process. This is completely different from the first moment
(`intensity') function of the point pattern, which is done by
'density.ppp' in spatstat and by 'kernel2d' in splancs.
The commands density.ppp (spatstat) and kernel2d (splancs) take a point
pattern, and effectively replace each point in the pattern by a copy of the
kernel, then add up these kernels to get an intensity function.
The command Kmeasure (spatstat) takes a point pattern, forms the list of
all PAIRS of distinct points in the pattern, computes the vectors that join
the first point to the second point in each pair, treats these vectors
as a pattern of `points', and applies a kernel smoother to them.
Kmeasure is a generalisation of Ripley's K-function. The value of K(r) is
equal to the total integral of the pixel values of the Kmeasure image
inside a circle of radius r centred at the origin.
The main reason for looking at the second moment measure rather than just
the K-function is to look for anisotropic or shape effects.
If the point pattern was a regular hexagonal packing, then the Kmeasure image
would reveal the hexagonal shape.
`spatstat' is the only R package that provides this functionality,
as far as I know.
There are no well-established techniques for choosing the smoothing
parameter when estimating the second moment measure.
The algorithm given in mse2d (splancs) for choosing the smoothing bandwidth
for kernel2d (splancs) is not designed for, and is probably not appropriate
for, choosing the bandwidth for `Kmeasure'. I guess you could use it as a
ballpark figure / starting value to play around with.
In general terms, spatstat is by far the largest and most extensive R package
for analysing spatial point patterns. The writer's recommendation to
ignore this huge package is a bit misguided.
More information about the R-sig-Geo