Estimates Ripley's reduced second moment function K(r) from a point pattern in a window of arbitrary shape.
1 2 3
The observed point pattern,
from which an estimate of K(r) will be computed.
An object of class
Optional. Vector of values for the argument r at which K(r)
should be evaluated. Users are advised not to specify this
argument; there is a sensible default. If necessary, specify
Optional. Maximum desired value of the argument r.
This argument is for internal use only.
Optional. A character vector containing any selection of the
Optional. Efficiency threshold.
If the number of points exceeds
Optional. Calculations will be restricted to this subset of the window. See Details.
The K function (variously called “Ripley's K-function” and the “reduced second moment function”) of a stationary point process X is defined so that lambda K(r) equals the expected number of additional random points within a distance r of a typical random point of X. Here lambda is the intensity of the process, i.e. the expected number of points of X per unit area. The K function is determined by the second order moment properties of X.
An estimate of K derived from a spatial point pattern dataset can be used in exploratory data analysis and formal inference about the pattern (Cressie, 1991; Diggle, 1983; Ripley, 1977, 1988). In exploratory analyses, the estimate of K is a useful statistic summarising aspects of inter-point “dependence” and “clustering”. For inferential purposes, the estimate of K is usually compared to the true value of K for a completely random (Poisson) point process, which is K(r) = pi * r^2. Deviations between the empirical and theoretical K curves may suggest spatial clustering or spatial regularity.
Kest estimates the K function
of a stationary point process, given observation of the process
inside a known, bounded window.
X is interpreted as a point pattern object
ppp.object) and can
be supplied in any of the formats recognised by
The estimation of K is hampered by edge effects arising from the unobservability of points of the random pattern outside the window. An edge correction is needed to reduce bias (Baddeley, 1998; Ripley, 1988). The corrections implemented here are
the border method or “reduced sample” estimator (see Ripley, 1988). This is the least efficient (statistically) and the fastest to compute. It can be computed for a window of arbitrary shape.
Ripley's isotropic correction (see Ripley, 1988; Ohser, 1983). This is implemented for rectangular and polygonal windows (not for binary masks).
Translation correction (Ohser, 1983). Implemented for all window geometries, but slow for complex windows.
Rigid motion correction (Ohser and Stoyan, 1981). Implemented for all window geometries, but slow for complex windows.
Uncorrected estimate. An estimate of the K function without edge correction. (i.e. setting e[i,j] = 1 in the equation below. This estimate is biased and should not be used for data analysis, unless you have an extremely large point pattern (more than 100,000 points).
Selects the best edge correction that is available for the geometry of the window. Currently this is Ripley's isotropic correction for a rectangular or polygonal window, and the translation correction for masks.
Selects the best edge correction
that can be computed in a reasonable time.
This is the same as
"best" for datasets with fewer
than 3000 points; otherwise the selected edge correction
"border", unless there are more than 100,000 points, when
The estimates of K(r) are of the form
Kest(r) = (a/(n * (n-1))) * sum[i,j] I(d[i,j] <= r) e[i,j])
where a is the area of the window, n is the number of
data points, and the sum is taken over all ordered pairs of points
i and j in
Here d[i,j] is the distance between the two points,
and I(d[i,j] <= r) is the indicator
that equals 1 if the distance is less than or equal to r.
The term e[i,j] is the edge correction weight (which
depends on the choice of edge correction listed above).
Note that this estimator assumes the process is stationary (spatially
homogeneous). For inhomogeneous point patterns, see
If the point pattern
X contains more than about 3000 points,
the isotropic and translation edge corrections can be computationally
prohibitive. The computations for the border method are much faster,
and are statistically efficient when there are large numbers of
points. Accordingly, if the number of points in
nlarge, then only the border correction will be
will prevent this from happening.
nlarge=0 is equivalent to selecting only the border
X contains more than about 100,000 points,
even the border correction is time-consuming. You may want to consider
correction="none" in this case.
There is an even faster algorithm for the uncorrected estimate.
Approximations to the variance of Kest(r)
are available, for the case of the isotropic edge correction estimator,
assuming complete spatial randomness
(Ripley, 1988; Lotwick and Silverman, 1982; Diggle, 2003, pp 51-53).
var.approx=TRUE, then the result of
Kest also has a column named
giving values of Ripley's (1988) approximation to
and (if the window is a rectangle) a column named
values of Lotwick and Silverman's (1982) approximation.
If the argument
domain is given, the calculations will
be restricted to a subset of the data. In the formula for K(r) above,
the first point i will be restricted to lie inside
domain. The result is an approximately unbiased estimate
of K(r) based on pairs of points in which the first point lies
domain and the second point is unrestricted.
This is useful in bootstrap techniques. The argument
should be a window (object of class
"owin") or something acceptable to
as.owin. It must be a subset of the
window of the point pattern
Kest ignores marks.
Its counterparts for multitype point patterns
and for general marked point patterns
Some writers, particularly Stoyan (1994, 1995) advocate the use of the “pair correlation function”
g(r) = K'(r)/ ( 2 * pi * r)
where K'(r) is the derivative of K(r).
pcf on how to estimate this function.
An object of class
which can be plotted directly using
Essentially a data frame containing columns
the vector of values of the argument r at which the function K has been estimated
the theoretical value K(r) = pi * r^2 for a stationary Poisson process
together with columns named
according to the selected edge corrections. These columns contain
estimates of the function K(r) obtained by the edge corrections
var.approx=TRUE then the return value
also has columns
ls containing approximations
to the variance of Kest(r) under CSR.
ratio=TRUE then the return value also has two
containing the numerators and denominators of each
estimate of K(r).
To compute simulation envelopes for the K-function
under CSR, use
To compute a confidence interval for the true K-function,
The estimator of K(r) is approximately unbiased for each fixed r. Bias increases with r and depends on the window geometry. For a rectangular window it is prudent to restrict the r values to a maximum of 1/4 of the smaller side length of the rectangle. Bias may become appreciable for point patterns consisting of fewer than 15 points.
While K(r) is always a non-decreasing function, the estimator of K is not guaranteed to be non-decreasing. This is rarely a problem in practice.
Baddeley, A.J. Spatial sampling and censoring. In O.E. Barndorff-Nielsen, W.S. Kendall and M.N.M. van Lieshout (eds) Stochastic Geometry: Likelihood and Computation. Chapman and Hall, 1998. Chapter 2, pages 37–78.
Cressie, N.A.C. Statistics for spatial data. John Wiley and Sons, 1991.
Diggle, P.J. Statistical analysis of spatial point patterns. Academic Press, 1983.
Ohser, J. (1983) On estimators for the reduced second moment measure of point processes. Mathematische Operationsforschung und Statistik, series Statistics, 14, 63 – 71.
Ohser, J. and Stoyan, D. (1981) On the second-order and orientation analysis of planar stationary point processes. Biometrical Journal 23, 523–533.
Ripley, B.D. (1977) Modelling spatial patterns (with discussion). Journal of the Royal Statistical Society, Series B, 39, 172 – 212.
Ripley, B.D. Statistical inference for spatial processes. Cambridge University Press, 1988.
Stoyan, D, Kendall, W.S. and Mecke, J. (1995) Stochastic geometry and its applications. 2nd edition. Springer Verlag.
Stoyan, D. and Stoyan, H. (1994) Fractals, random shapes and point fields: methods of geometrical statistics. John Wiley and Sons.
localK to extract individual summands in the K
pcf for the pair correlation.
reduced.sample for the calculation of reduced sample
1 2 3 4 5 6 7 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.