ripk
Ripley’s K function
ripk(x, y = NULL, win, r, corr = "iso", metric = "euclid")Ripley’s K function of a point pattern in the rectangle win at radii
r, and Besag’s L = sqrt(K / pi). Under complete spatial randomness
K(r) = pi r^2 and L(r) = r. Four estimators: "none" (no edge
correction), "border" (only points at least r from the edge are
centres), "modif" (the modified border estimator, with the area of the
eroded window; NaN once r reaches half a side) and "iso" (Ripley’s
isotropic correction, each pair weighted by the inverse of the share of
the circle through the other point that lies in the rectangle, computed
exactly). The normalisation is n (n - 1), as in spatstat.
Parameters
Section titled “Parameters”x, yThe points in planar coordinates (project longitude and latitude with
eqproj()first):xandynumeric vectors of equal length, orxa matrix or data frame with columns namedxandy(an unnamed two-column matrix is read asxtheny). At least two points, all insidewin; no missing values.winThe study rectangle
c(xmin, xmax, ymin, ymax), in the unit of the coordinates. The intensity is the number of points over its area.rThe radii: non-negative numbers in strictly increasing order, in the unit of the coordinates.
corrThe edge correction:
"iso","border","modif"or"none".metricThe distance:
"euclid"or"manhattan"(|dx| + |dy|, a street grid aligned with the axes), as inspwt()andjtsurf(). Under Manhattan distanceK(r) = 2 r^2andL = sqrt(K / 2)under randomness; the border and modified border corrections carry over (a Manhattan ball of radiusrlies in the rectangle exactly when its centre is at leastrfrom every edge), while the isotropic correction, the share of a circle, has no Manhattan form and is refused.
Returns
Section titled “Returns”A data frame with one row per radius: r, k (in the square of
the coordinates’ unit) and l (sqrt(k / pi), or sqrt(k / 2) under
Manhattan distance).
References
Section titled “References”Ripley, B. D. (1976). The second-order analysis of stationary point processes. Journal of Applied Probability, 13(2), 255-266. doi:10.2307/3212829
Ripley, B. D. (1977). Modelling spatial patterns. Journal of the Royal Statistical Society, Series B, 39(2), 172-212. doi:10.1111/j.2517-6161.1977.tb01615.x
Examples
Section titled “Examples”set.seed(1)ripk(runif(100), runif(100), win = c(0, 1, 0, 1), r = seq(0, 0.25, 0.05))Generated from the R help page: ripk in the R reference.