MerQuR+Statistics Glossary

Statistics Glossary → Point Pattern Analysis (Ripley K/L, G/F/J, CSR)

Point Pattern Analysis (Ripley K/L, G/F/J, CSR)analysis

Methods (Ripley's K/L, G/F/J, Clark-Evans, the quadrat test) that test whether point locations within an area are randomly scattered or more clustered or more regular than expected, and at which distance scale this holds.

Concept

When trees, nests, cells or events are scattered over an area, the basic question is: were these locations chosen independently and at random, or do the points attract one another (clustering) or repel one another (regularity)? The benchmark is complete spatial randomness (CSR): a homogeneous Poisson process in which points fall anywhere in the area with equal probability and independently of each other. Clustering may point to processes such as seeds falling near the parent tree, regularity to competition for resources or space.

Summary functions describe the pattern by distance. Ripley's K(r) is the expected number of points within radius r of a point divided by the intensity; under CSR it equals πr², and larger values indicate clustering. L(r) = √(K(r)/π) turns this comparison into a straight line, while the pair correlation g(r) gives the relative frequency of pairs at exactly distance r (above 1 means clustering). G(r) is the distribution of nearest-neighbour distances and F(r) that of distances from a random location to the nearest point; J = (1 − G)/(1 − F) below 1 indicates clustering and above 1 regularity. The Clark-Evans index is the ratio of the mean nearest-neighbour distance to its expectation under CSR (below 1 clustered, above 1 regular), and the quadrat test compares cell counts with a chi-square test. Monte Carlo envelopes draw the range of the functions obtained from patterns simulated under CSR; if the observed curve leaves the envelope, there is a departure from CSR.

The results depend heavily on defining the observation window correctly: if the window is smaller or larger than the true study area, the intensity is misestimated and spurious clustering or regularity can appear. Edge corrections are needed because the neighbours of points near the edge may lie outside the window. Pointwise envelopes test many r values separately, so the chance of a false alarm is high; for a single overall decision, a global envelope or the MAD test should be used. Also, a departure from CSR can arise because some parts of the area are naturally more suitable (inhomogeneous intensity); this must be distinguished from interaction between points.

When to use it

  • To test whether the locations of plants, animal nests, cells or events are random, clustered or regular, and at which distances this holds.
  • If a single quick overall measure is enough, use the Clark-Evans index; to examine how the pattern changes with distance scale, use the K, L and g functions with Monte Carlo envelopes.
  • If one only wants to see where the points are concentrated, use KDE; if the points are to be assigned to clusters, DBSCAN; if the spatial similarity of a value measured at the points is in question, Moran's I is preferred.

An everyday example

An ecologist maps the positions of 80 ant nests in a one-hectare meadow. One view holds that because each colony defends the food around it, the nests should keep their distance from one another, that is, be regularly spaced; another holds that the nests should gather in damp hollows. The Clark-Evans index comes out at 1.35 and nearest-neighbour distances are longer than expected at random: the pattern is regular. The L function shows that the regularity is clear especially up to about 3 metres, while at larger distances the pattern cannot be told apart from random; this supports the interpretation that competition dominates at short range.

Parameters in MerQur

Classify by / Method

Concept: Classify is a data-exploration step that colours the points by a categorical column before the analysis; Method chooses the analysis to run on the map tab. Point pattern analysis tests whether the locations themselves are random.

Everyday example: Colouring the nests by ant species shows in advance whether the two species' nests gather in different parts of the meadow. For the question 'do the nests keep their distance from one another?', point pattern analysis is chosen.

What it does: Classify by colours the points by category (data exploration); Method selects the map method.

Effect on the result: Does not change the numeric output.

Coordinate type (Geographic, Projected (X / Y)), X (easting), Y (northing), Coordinate unit (m, km, unitless)

Concept: Sets the coordinate system in which distances are measured. Geographic coordinates (degrees) are moved onto a local plane and converted to km; projected coordinates (metres, km or unitless) are used as they are, and the r distances in the results are read in that unit.

Everyday example: If the ecologist recorded the nest positions as x, y values in metres measured from a corner of the meadow, projected and 'm' are chosen. A value of '3' on the L function then means 3 metres directly.

What it does: With the geographic choice the points are carried onto the same local equirectangular plane (km) as the other map analyses (including the 0-360 longitude and 180th meridian rules; a warning above 500 km width). With the projected choice the X/Y columns are used as they are.

Effect on the result: Determines the distance scale and the unit of the r axis.

On the validation data: The Diggle data are run in the unit square with projected (unitless) coordinates.

→ Distance measure (Euclidean, Manhattan, Gower, great-circle)

Observation window (Bounding box, Convex hull, Rectangle entered manually, Polygon layer) and rectangle limits (x min, x max, y min, y max) and Polygon layer

Concept: The observation window is the boundary of the area in which points could occur, and the expected intensity is computed relative to it. A bounding box or convex hull derived from the points underestimates the true area and overstates the intensity; if the study area is known, its boundary (a rectangle or polygon) should be used.

Everyday example: If the meadow is 100 × 100 metres but all the nests lie in the central 70 × 70 metres, using the points' bounding box leaves the meadow's empty margins out of the analysis. With the true meadow boundary, by contrast, the nests appear gathered in the middle, that is, more clustered; which is right depends on whether nests could also be built in the margins.

What it does: Defines the analysis region W. The bounding box and convex hull are derived from the points (they underestimate the area and slightly exaggerate the density); if the real study area is known, a manual rectangle or a polygon layer should be used. Points outside the window are dropped and reported.

Effect on the result: Changes the density (lambda), edge corrections and all function and test values.

On the validation data: The redwood area is 1 in the unit square window; 0.6180555 in the convex hull of the points.

→ Observation window (study region)

Summary functions: K, L, g, G, F, J (check boxes)

Concept: Each function looks at the pattern from a different angle: K and L summarise the cumulative number of neighbours within radius r, g the frequency of pairs at exactly distance r, G nearest-neighbour distances, F the size of empty spaces, and J the comparison of G with F. Under CSR each has a known expected value, and the direction of departure shows clustering or regularity.

Everyday example: For regularly spaced nests the G function stays below its CSR expectation at short distances, because few nests have a very close neighbour. The g function shows more sharply at exactly which distance the nests 'avoid' each other.

What it does: K(r): the expected number of neighbours within r divided by the density (pi r^2 under CSR); L(r) = sqrt(K(r) / pi); g(r): the relative frequency of pairs at distance r (greater than 1 clustering); G(r): the nearest neighbour distance distribution; F(r): the empty space distance distribution; J(r) = (1 - G) / (1 - F) (less than 1 clustering).

Effect on the result: Only the tables and graphs of the selected functions are produced.

On the validation data: For each dataset K, L (border), g, G (rs), F and J are computed at 100 r values.

→ Ripley's K/L and the G, F, J functions

Number of CSR simulations (No envelope, 19, 39, 99, 199, 499, 999), Envelope rank (nrank) and Fixed n check box ([Parameters])

Concept: A Monte Carlo envelope simulates many artificial patterns under CSR and computes the function for each, drawing the band within which 'the curve would wander if the pattern were random'. The number of simulations and the rank (nrank) set the envelope's significance level; the fixed-n option uses as many points in each simulation as were observed.

Everyday example: Maps are produced in which the 80 nests are placed at random 99 times. If the real nests' L curve lies below all 99 curves, the regularity cannot be put down to chance; with a global envelope this decision is made at about the 1% level.

What it does: Determines the number of CSR simulations for the Monte Carlo envelope (default 99). nrank is the order statistic taken as the envelope limit; in the pointwise envelope alpha = 2 nrank / (nsim + 1), in the global envelope nrank / (nsim + 1). If Fixed n is checked, simulations are generated with the observed n.

Effect on the result: Determines the envelope width and the MAD p value; does not change the functions and tests. The pointwise envelope is not corrected for multiple comparisons (a warning is given).

On the validation data: The K, L, g, G pointwise and global envelopes, D_obs and MAD p are computed with nrank 1 and 2 and nsim 39 and 99.

→ Monte Carlo (simulation) envelope

Seed (0 = automatic)

Concept: The seed is the starting point of the random number sequence that generates the CSR simulations. The same seed reproduces the same envelope and the same Monte Carlo p value.

Everyday example: The ecologist reports the seed used so that a reviewer can reproduce the envelope plot in the paper. A different seed moves the envelope limits slightly, but a strong conclusion of regularity does not change.

What it does: Determines the random number seed of the simulations; the same seed gives the same envelope.

Effect on the result: Affects only the envelope and the MAD p value.

On the validation data: Seed 20261015 in the default run.

→ Random seed

Quadrat counts (columns x rows; default 5 x 5)

Concept: The quadrat test divides the window into equal cells and uses a chi-square test to check whether the cell counts fit the even spread expected under CSR. The result depends on the cell size; if the expected count per cell is below 5, the chi-square approximation may be unreliable.

Everyday example: If the meadow is divided into 4 × 4 = 16 cells, 5 nests are expected in each on average. Under a regular pattern the counts vary around 5 less than expected; under a clustered one some cells are empty and others crowded.

What it does: Divides the bounding box of the window into nx x ny cells and performs the chi-square goodness-of-fit test of the cell counts (default 5 x 5); in a polygon window clipped cell areas are used.

Effect on the result: Determines X2, degrees of freedom and the p value.

On the validation data: redwood 5 x 5: X2 54.93548387 (df 24, p 0.00063873436, expected frequency 2.48); 3 x 4: X2 16.58064516 (df 11, p 0.2418129358). cells 5 x 5: X2 9.19047619 (p 0.005678622753).

→ Quadrat count test

Clark-Evans correction (Automatic, None, Donnelly, cdf (G function))

Concept: The Clark-Evans index compares the mean nearest-neighbour distance with its expected value under CSR. Because the true nearest neighbour of a point near the window edge may lie outside the window, distances are measured too long and the index is biased towards regularity; the Donnelly and cdf corrections remove this edge effect.

Everyday example: A nest near the meadow fence may have its nearest neighbour on the other side of the fence, which is not on the map. Without a correction such nests look further from their neighbours than they are, and the pattern seems more regular than it really is.

What it does: Determines the edge correction of the Clark-Evans nearest neighbour index (automatic: Donnelly in a rectangle, cdf in a polygon).

Effect on the result: Changes the Clark-Evans index and the test statistic.

On the validation data: redwood (unit square): index (uncorrected) 0.6068936706, Donnelly 0.5738737871, cdf 0.561366401; Donnelly test p 1.13493112e-11. In the convex hull cdf 0.6526020721.

→ Edge (boundary) correction

Alternative hypothesis (Two-sided, Clustering, Regularity)

Concept: Sets the direction of the alternative hypothesis in the Clark-Evans and quadrat tests: a two-sided test looks for any departure, while one-sided tests look only for clustering or only for regularity. The direction should be chosen from the research question, without looking at the data.

Everyday example: If, based on competition theory, the ecologist asks only 'are the nests regularly spaced?', the regularity direction is chosen. If it is unknown whether clustering or regularity is expected, a two-sided test is used.

What it does: Determines the alternative hypothesis of the Clark-Evans and quadrat count tests.

Effect on the result: Changes only the p value. With Clustering the quadrat count p is the upper tail, with Regularity the lower tail; the Clark-Evans p is one-sided in the same direction.

On the validation data: Quadrat p with Clustering: redwood 5 x 5 0.000319367 (two-sided 0.000638734), 3 x 4 0.120906; cells 5 x 5 0.997161.

→ One-sided and two-sided tests (hypothesis direction)

Upper limit of r (K, L, g) and Upper limit of r (G, F, J) (0 = automatic)

Concept: The largest distance r at which the functions are computed. At very large r most pairs cannot be observed because of the window edge, so the estimates become unreliable; the upper limit is therefore usually capped at something like a quarter of the window's shorter side.

Everyday example: In a 100-metre meadow the distances that matter for ant competition are a few metres; raising the upper r to 50 metres produces a tail of the curve distorted by edge effects and hard to interpret. A limit of around 25 metres is more meaningful.

What it does: Determines the upper limit of the r grid. In automatic, for K, L, g the smaller of 1/4 of the short side of the window and sqrt(1000 / (pi lambda)); for G, F, J the smaller of sqrt(log(1e5) / (pi lambda)) and half of the frame diagonal.

Effect on the result: Determines the range of the functions.

On the validation data: The default grids are built by the automatic rule. With an upper limit of 0.25, K, L and g are computed at 513 equally spaced r values between 0 and 0.25 (step 0.25/512).

→ Ripley's K/L and the G, F, J functions

g(r) zero-boundary correction (Automatic, Jones-Foster, Convolution, None)

Concept: The pair correlation function g(r) is estimated by kernel smoothing, and near r = 0 part of the kernel spills over into negative distances, biasing g at distances close to zero. The zero correction (Jones-Foster, convolution) reduces this bias.

Everyday example: If nests are known never to be closer than 30 cm, g should be close to zero in that range. Without the correction, g values at these very short distances can be misleading and the 'avoidance' distance may be misread.

What it does: Determines the correction for the loss of kernel mass at the r = 0 boundary (Epanechnikov kernel, h = 0.15 / sqrt(lambda); in automatic, Jones-Foster if n <= 300, otherwise convolution).

Effect on the result: Affects only the small r values of g(r).

On the validation data: Jones-Foster in the default run (n = 62).

→ Edge (boundary) correction

Value (none, column)

Concept: Point pattern analysis uses only the locations; any value carried by the points does not enter these tests.

Everyday example: Even if the number of workers in each nest has been recorded, this analysis uses only where the nests are. If the question is whether large colonies lie near one another, a value-based method such as Moran's I is needed.

What it does: Not used in this analysis.

Effect on the result: The selection does not change the result.

Example on real data

Data: Strauss 1975, Diggle 2014 data archive (redwood)

Variables: 62 redwood seedlings, projected X/Y (x, y; unitless), window the unit square [0, 1] x [0, 1]; seed 20261015

  • Question: Do the locations of the 62 redwood seedlings depart from complete spatial randomness (CSR), and if so, towards clustering or regularity?
  • Assumption: The window is the unit square [0, 1] x [0, 1]; under CSR the points form a homogeneous Poisson process (λ = 62).
  • Result: Clark-Evans index = 0.574 (Donnelly), z = -6.79, p < .001; nearest neighbour distances are shorter than expected under randomness, the pattern is clustered. Quadrat test χ²(24) = 54.94, p < .001.
  • Scale finding: The K, L and G functions rise above the global envelope of 99 CSR simulations and F falls below it (MAD p = .010); g and J leave only the pointwise envelope. Clustering is marked at short and medium distances.
  • Limitation: In the quadrat test the smallest expected count is 2.48 (< 5), so the chi-square approximation may be unreliable; with 99 simulations the MAD p has a resolution of at most 0.01.
  • Report line: Clark-Evans index = 0.574, z = -6.79, p < .001; quadrat χ²(24) = 54.94, p < .001; L(r) MAD test p = .010 (99 simulations).

Related concepts

Ripley's K/L and the G, F, J functionsEdge (boundary) correctionMonte Carlo (simulation) envelopeQuadrat count testObservation window (study region)Complete spatial randomness (CSR)Clark-Evans nearest-neighbour indexOne-sided and two-sided tests (hypothesis direction)

The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.