Skip to contents

The raw empirical CDF of nearest-neighbour distances is biased downward near the edge of the window: a point close to the boundary may have its true nearest neighbour outside it, so the observed distance is too large. The reduced-sample (border) correction removes exactly the points that could be affected at each radius, G_hat(r) = #{i : d_i <= r and b_i > r} / #{i : b_i > r}, where d_i is the observed nearest-neighbour distance and b_i the distance from point i to the nearest window edge. The complete spatial randomness benchmark is G_csr(r) = 1 - exp(-lambda pi r^2), so G_hat above it indicates clustering and below it regularity.

Usage

Nndist(coords, r_grid, window = NULL)

Arguments

coords

Point coordinates, n by 2.

r_grid

Non-negative radii at which to evaluate G.

window

c(xmin, ymin, xmax, ymax) or an (m, 2) vertex matrix; defaults to the bounding box of coords.

Value

List with G, G_csr, r, m_used, estimate, lambda_hat, n.

References

Diggle, P. J. (2003). Statistical Analysis of Spatial Point Patterns, 2nd edition, Arnold; section 2.3 defines G and section 4.3 the border correction.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
M <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
Nndist(M, V)
#> $G
#> [1] NA NA NA NA NA NA NA NA
#> 
#> $G_csr
#> [1] 0.9981326 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000 1.0000000
#> [8] 1.0000000
#> 
#> $r
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $m_used
#> [1] 0 0 0 0 0 0 0 0
#> 
#> $estimate
#> [1] 1.732051
#> 
#> $lambda_hat
#> [1] 2
#> 
#> $n
#> [1] 2
#> 
#> $method
#> [1] "Border-corrected nearest-neighbour distance CDF G(r)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"