Help with the Kmeasure function from the Spatstat package
Adrian, I'm sure your description of Kmeasure is very welcome, and gives a foretaste of what the e-recipe book on http://www.spatstat.org/ will offer. Given the rapid development in the spatstat package, and the large number of contributors to the package, it is perhaps worth saying that spatstat is the only package for analysing spatial point patterns among the three commonly referenced packages: spatial (supporting the book MASS), splancs (originally written for S in the early 1990s), and spatstat, that is under active development. Both spatial and splancs represent the ways spatial point patterns were analysed at the time they were written, and constitute a useful record of where the subject has come from. Only spatstat shows where the subject is going, supplemented by a number of narrower packages, such as MarkedPointProcess. Only spatstat has a rich range of S3 classes for point pattern objects - the maptools package now contains wrappers for moving between classes defined in spatstat and those S4 classes defined in the sp package. Having splancs and spatial available, it is convenient to cross-check how implementation may impact output for shared methods of analysis. They are also useful for following up and reproducing published work documented as using them, such as MASS and the point pattern chapters in Bailey and Gatrell, so they will be maintained in the future. Roger PS. Using spatstat, I notice that if the boot package is loaded, its envelope() function gets masked by the function of the same name in spatstat. Unfortunately, both have many named arguments, but the spatstat one could dispatch on class ppp or ppm, and the boot one on class boot or default. Maybe an S3 method with envelope(Y, ...) would be a way out?
On Fri, 8 Dec 2006, Adrian Baddeley wrote:
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. Adrian Baddeley
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no