Session Ready
Exercise

Nearest-neighbor distributions

Another way of assessing clustering and regularity is to consider each point, and how it relates to the other points. One simple measure is the distribution of the distances from each point to its nearest neighbor.

The nndist() function in spatstat takes a point pattern and for each point returns the distance to its nearest neighbor. You can then plot the histogram.

Instead of working with the nearest-neighbor density, as seen in the histogram, it can be easier to work with the cumulative distribution function, G(r). This is the probability of a point having a nearest neighbor within a distance r.

For a uniform Poisson process, G can be computed theoretically, and is G(r) = 1 - exp( - lambda * pi * r ^ 2). You can compute G empirically from your data using Gest() and so compare with the theoretical value.

Events near the edge of the window might have had a nearest neighbor outside the window, and so unobserved. This will make the distance to its observed nearest neighbor larger than expected, biasing the estimate of G. There are several methods for correcting this bias.

Plotting the output from Gest shows the theoretical cumulative distribution and several estimates of the cumulative distribution using different edge corrections. Often these edge corrections are almost indistinguishable, and the lines overlap. The plot can be used as a quick exploratory test of complete spatial randomness.

Instructions
100 XP

Two ppp objects, p_poisson, and p_regular are defined for you.

  • Pass the Poisson point pattern to nndist() to find the nearest neighbor of each point, assigning the result to nnd_poisson.
  • Plot the histogram of the nearest neighbor distances for the Poisson point data.
  • Estimate G(r) for the Poisson point pattern by passing p_poisson to Gest(). Assign the result to G_poisson.
  • Plot G(r) vs. r by passing the estimate (G_poisson) to plot().
  • Repeat the previous four steps using the regular point pattern.