# A Statistical Test for Ripley’sK Function Rejection of Poisson Null Hypothesis

Authors: Eric Marcon; Stéphane Traissac; Gabriel Lang
Journal: ISRN Ecology
 (2013)

---

## Abstract

Ripley’sK function is the classical tool to characterize the spatial structure of point patterns. It is widely used in vegetation studies. Testing its values against a null hypothesis usually relies on Monte-Carlo simulations since little is known about its distribution. We introduce a statistical test against complete spatial randomness (CSR). The test returns the P value to reject the null hypothesis of independence between point locations. It is more rigorous and faster than classical Monte-Carlo simulations. We show how to apply it to a tropical forest plot. The necessary R code is provided.


---

## Body

## 1. Introduction

The commonest tool used to characterize the spatial structure of a point set is Ripley'sK statistic [1, 2]. It has been widely used in ecology and other scientific fields and is well referenced in handbooks [3–7]. Classically, an observed set of points is tested against a homogeneous Poisson point process taken as a null model. Since little is known about the distribution of the K function, the test of rejection of the null hypothesis relies on Monte-Carlo simulations. Large point patterns are difficult to deal with because computation time is roughly proportional to the square of the number of points (to calculate the distances between all pairs of points) multiplied by the number of simulations. Moreover, the test is valid for one distance but using it repeatedly for all distances where the K function is calculated dramatically increases the risk to reject the null hypothesis by error [8]. Duranton and Overman [9] provided a heuristic global test followed by Marcon and Puech [10]. Loosmore and Ford proposed a goodness-of-fit test to eliminate this error, but still rely on Monte-Carlo simulations.We showed in [11] that a global test was able to return a classical P value, that is to say, the probability to erroneously reject the null model, relying on exact values of the biases and variances of the statistics. We derived its asymptotic properties in a growing square window. We develop it in this paper so that it can be used in a rectangular window, as most applications require. We show that it can be applied to real point patterns, even with a little number of points and discuss in depth the way to employ it, so that it can be used by empirical researchers.We first present our motivating example: a tropical forest plot where we want to elucidate the spatial structure of two species of trees. We provide the mathematical framework supporting the test. We apply it to the dataset and present the results. In the Discussion, we review the literature of previous tests to show why this one is a significant improvement and we verify that the test actually works. Finally, we provide a user guide to allow researchers to easily apply the test with the provided R [12] code.


## 2. Materials and Methods

### 2.1. Data to Analyze

We consider the distribution of two tree species in Paracou field station, French Guiana [13]. All trees over 10 cm DBH have been plotted. We use data from a 400.6 by 522.3 meters rectangle included in the four plots of the southern block of the experimental device. A map of trees is in Figure 1.Map ofTachigali melinonii (94 trees, (a)) and Dicorynia guianensis (254 trees, (b)).
(a)
(b)Dicorynia guianensis Amsh. is a widely studied species in French Guiana; its spatial structure has been characterized for a long time [14, 15]; as a visual inspection of the map allows to guess, Dicorynia guianensisis an aggregated species.Much less is known aboutTachigali melinonii (Harms) Barneby. The species has been studied for its special biomechanical behavior [16] or leaf trait plasticity [17]. The spatial structure of its saplings has been reported by Flores et al. [18] but the structure of adult trees is not clear.


### 2.2. Mathematical Framework

We consider a point pattern in a rectangular window.l1 and l2 are the sides of the window (width and length). ρ is the intensity of the underlying point process; estimated by the number of observed points N divided by the area of the window. We denote by r the vector of distances (r1,…,ri,…,rd). We omit the subscript for readability when there is no ambiguity; r is one of the distances, and K^(r) is the estimator of K at distance r. Points are denoted by ξi, and I{d(ξi,ξj)≤r} is an indicator function equal to 1 when the distance between two points is less than or equal to r, 0 else. Details of the calculation are not provided as we follow exactly Lang and Marcon [11] but its important steps and intuitions are presented here.Ripley’sK function is estimated from the data for each distance r, without correction for edge effects:
(1)K^(r)=l1l2N(N-1)∑ξi≠ξjI{d(ξi,ξj)≤r}.Assumptions are those of Ripley’sK function: we test the independence of locations of an observed point pattern, assumed to be a realization of a homogenous point process. Homogeneity means both stationarity (the process in unchanged by translation) and isotropy (the process is unchanged by rotation). Thus the null hypothesis of complete spatial randomness (CSR) is that the point process is a homogenous Poisson process.The expectation ofK(r) under CSR is πr2. Edge effects introduce a bias in K^(r), computed for the null model:
(2)B(r)=-4r3(l1+l2)3l1l2+r42l12l22.EstimatedK^(r) can be corrected for the bias of the null model to test them against it. We get a vector of results of length d:
(3)K^=(K^(r1)-B(r1),K^(r2)-B(r2),…,K^(rd)-B(rd)).For a homogenous point process the vectorK^-πr2 is asymptotically normal, with expectation zero and the explicit variance matrix Σ:
(4)Σ=(Var(K^(r1))⋯cov(K^(r1),K^(rd))⋮⋱⋮cov(K^(r1),K^(rd))⋯Var(K^(rd))).ConsequentlyT2=∥Σ-1/2(K^-πr2)∥2 follows a χ2 law with d degrees of freedom. Asymptotic value of the variance is reached with dozens of thousand points, so it is of little use, but normality is acceptable with very few points so the test can be used with real data, as the exact value of Σ can be calculated. The exact calculation of variance and covariance is quite painful because it takes into account the edge effects, resulting in the formulas given in Appendix A.


### 2.3. Application

The test is applied as follows: (i) computeK^-πr2 from the observed point pattern, following (3); (ii) compute Σ according to the window’s size and the number of observed points; (iii) finally compare T2=∥Σ-1/2(K^-πr2)∥2 to a χ2 distribution with d degrees of freedom and return the P value.We provide a classical plot ofL(r)=K(r)/π-r [19] against r, computing every 5 meters up to 250 m (to illustrate the discussion). 1,000 simulations of a binomial process with the same number of points as the real data are run. At each distance r, the 25 lower and greater values are eliminated to build the local 5% confidence interval. The global confidence interval is built iteratively [9, 10]; simulations corresponding to extreme values (maximum or minimum) at any distance are eliminated. This process is repeated until 5% of the simulations are concerned. The extreme remaining values are plotted. Interpolation is used if the last iteration eliminates more simulations than required.We apply our test to these two point sets, up to 150 meters following Collinet [15] who characterized the spatial structure of many species in Paracou and detected possible dependence at this scale. The vector of distances is r=(10,20,…,150) meters; we discuss this choice later. Finally, we apply Loosmore and Ford’s test based on the same r and 1,000 simulations.


## 2.1. Data to Analyze

We consider the distribution of two tree species in Paracou field station, French Guiana [13]. All trees over 10 cm DBH have been plotted. We use data from a 400.6 by 522.3 meters rectangle included in the four plots of the southern block of the experimental device. A map of trees is in Figure 1.Map ofTachigali melinonii (94 trees, (a)) and Dicorynia guianensis (254 trees, (b)).
(a)
(b)Dicorynia guianensis Amsh. is a widely studied species in French Guiana; its spatial structure has been characterized for a long time [14, 15]; as a visual inspection of the map allows to guess, Dicorynia guianensisis an aggregated species.Much less is known aboutTachigali melinonii (Harms) Barneby. The species has been studied for its special biomechanical behavior [16] or leaf trait plasticity [17]. The spatial structure of its saplings has been reported by Flores et al. [18] but the structure of adult trees is not clear.


## 2.2. Mathematical Framework

We consider a point pattern in a rectangular window.l1 and l2 are the sides of the window (width and length). ρ is the intensity of the underlying point process; estimated by the number of observed points N divided by the area of the window. We denote by r the vector of distances (r1,…,ri,…,rd). We omit the subscript for readability when there is no ambiguity; r is one of the distances, and K^(r) is the estimator of K at distance r. Points are denoted by ξi, and I{d(ξi,ξj)≤r} is an indicator function equal to 1 when the distance between two points is less than or equal to r, 0 else. Details of the calculation are not provided as we follow exactly Lang and Marcon [11] but its important steps and intuitions are presented here.Ripley’sK function is estimated from the data for each distance r, without correction for edge effects:
(1)K^(r)=l1l2N(N-1)∑ξi≠ξjI{d(ξi,ξj)≤r}.Assumptions are those of Ripley’sK function: we test the independence of locations of an observed point pattern, assumed to be a realization of a homogenous point process. Homogeneity means both stationarity (the process in unchanged by translation) and isotropy (the process is unchanged by rotation). Thus the null hypothesis of complete spatial randomness (CSR) is that the point process is a homogenous Poisson process.The expectation ofK(r) under CSR is πr2. Edge effects introduce a bias in K^(r), computed for the null model:
(2)B(r)=-4r3(l1+l2)3l1l2+r42l12l22.EstimatedK^(r) can be corrected for the bias of the null model to test them against it. We get a vector of results of length d:
(3)K^=(K^(r1)-B(r1),K^(r2)-B(r2),…,K^(rd)-B(rd)).For a homogenous point process the vectorK^-πr2 is asymptotically normal, with expectation zero and the explicit variance matrix Σ:
(4)Σ=(Var(K^(r1))⋯cov(K^(r1),K^(rd))⋮⋱⋮cov(K^(r1),K^(rd))⋯Var(K^(rd))).ConsequentlyT2=∥Σ-1/2(K^-πr2)∥2 follows a χ2 law with d degrees of freedom. Asymptotic value of the variance is reached with dozens of thousand points, so it is of little use, but normality is acceptable with very few points so the test can be used with real data, as the exact value of Σ can be calculated. The exact calculation of variance and covariance is quite painful because it takes into account the edge effects, resulting in the formulas given in Appendix A.


## 2.3. Application

The test is applied as follows: (i) computeK^-πr2 from the observed point pattern, following (3); (ii) compute Σ according to the window’s size and the number of observed points; (iii) finally compare T2=∥Σ-1/2(K^-πr2)∥2 to a χ2 distribution with d degrees of freedom and return the P value.We provide a classical plot ofL(r)=K(r)/π-r [19] against r, computing every 5 meters up to 250 m (to illustrate the discussion). 1,000 simulations of a binomial process with the same number of points as the real data are run. At each distance r, the 25 lower and greater values are eliminated to build the local 5% confidence interval. The global confidence interval is built iteratively [9, 10]; simulations corresponding to extreme values (maximum or minimum) at any distance are eliminated. This process is repeated until 5% of the simulations are concerned. The extreme remaining values are plotted. Interpolation is used if the last iteration eliminates more simulations than required.We apply our test to these two point sets, up to 150 meters following Collinet [15] who characterized the spatial structure of many species in Paracou and detected possible dependence at this scale. The vector of distances is r=(10,20,…,150) meters; we discuss this choice later. Finally, we apply Loosmore and Ford’s test based on the same r and 1,000 simulations.


## 3. Results

Aggregation ofDicorynia guianensis is obvious on Figure 2(b). Our test applied with the vector of distances (10, 20, …, 150 meters) returns a P value equal to zero; that is to say, the quantile of the χ2 distribution with 15 degrees of freedom for T is so low that R returns 0. Loosmore and Ford’s test gives the same result with a value of their statistic u1 much greater than all simulations.L values for Tachigali melinonii (a) and Dicorynia guianensis (b). Distances are in meters. Confidence intervals are computed for the null hypothesis of complete spatial randomness at the 5% significance level. The local [4] and global [9] confidence intervals are calculated by Monte-Carlo simulations as explained in the text. Test P values are respectively 0 and 2.5%.
(a)
(b)Figure2(a) shows a less clear structure of Tachigali melinonii. The curve leaves the local confidence interval many times, but not the global one. Our test applied with the same distance vector (10 to 150 m) returns a P value equal to 2.5%; aggregation is significant.Loosmore and Ford’s test applied to the same distance range returns aP value equal to 1.7%±0.8% (u1 is ranked 984th among the 1,000 simulations).


## 4. Discussion

### 4.1. Foundations of the Test

Many methods exist to test a point pattern against CSR [7, page 83:98], among which the relative variance [20, 21] or tests based on the nearest neighbors [22–24]. Tests based on the K function are particularly appealing because K^ provides data about the relative position of points at different scales, and the function simultaneously gives useful information about the point process.


#### 4.1.1. The Distribution ofK^(r) under CSR Was Unknown

The classical, local test consists in comparing each observedK^(r) to the confidence interval of K^(r) obtained by Monte-Carlo simulations of the null model (which should be a homogenous Poisson point process, but is usually approximated by a binomial process for simplicity, artificially reducing variability). The null model is rejected at the chosen significance level, 5%, when the observed K^(r) is out of the corresponding confidence interval.To avoid simulations, approximate confidence intervals forK^(r) were proposed by Ripley [25], refuted by Koen [26] whose errors were finally corrected by Chiu [27]. All these confidence intervals were built on simulations.The variance ofK^(r) has been investigated early (see [5, page 58]). Asymptotic variance was calculated and asymptotic normality was proved, allowing calculating a confidence interval for K^(r), but the exact variance remains far from its asymptotic value for usual point sets [11]. We derived the exact variance in Appendix A.


#### 4.1.2. TestingK^(r) along Many Values of r Is Not Correct

In our examples, we have 30 values ofK^(r). If we draw a point pattern in a Poisson process we can expect 5% of them, that is, 1 or 2 of them, to be out of the confidence interval. As a consequence, the local significance level of the test should be decreased dramatically to have a global significance level of 5%. Actually, K^(r) are highly correlated because K is a cumulative function; roughly speaking, most of K^(r) values come from that of the previous one (see Figure 3). This reduces the need for a correction but does not eliminate it completely [28]. Since no quantification of the correction is available, the local test is used, keeping in mind that the global significance level of the test is somehow higher than announced (see [7, page 456] for a discussion). Each of the local confidence interval values is correct but testing a curve made of 30 points against local confidence envelope is not [8].(a) Plot ofK^ minus its expectation πr2 in two dimensions (r=2 and r=5) for 500 simulations of a Poisson process of intensity ρ=5 drawn in a square window of size 10 (500 points on average). (b) Comparison of values of T(2) and T(5), after transformation. Around 25 simulations of the homogenous point process out of 500 lie out of the critical circle corresponding to T2>χ5%2(2) so they are rejected by the test.
(a)
(b)To address this issue, solutions have been proposed. Duranton and Overman [9] proposed a test consisting in eliminating simulated K^ vectors globally when one of their values is an extreme one. Global confidence intervals plotted in the figures are heuristic; they do not rely on any mathematical proof. They appear to be too conservative for Tachigali melinonii.


#### 4.1.3. Goodness-of-Fit Tests Are a Solution

Goodness-of-fit (GoF) tests measure the discrepancy between the expected curve ofK under the null hypothesis and the actual curve. This value can be compared to its quantiles under CSR. Loosmore and Ford’s [8] test is a GoF test, already proposed by Diggle [4]. Its quantiles are not known so the test relies on Monte-Carlo simulations. Three GoF tests have been proposed by Heinrich [29] but all of them are asymptotic so none can be used with real data. Our test is very similar to Heinrich’s χ2 test, but as we derived the bias due to edge effects and the exact variance-covariance matrix of K^ under CSR, we were able to compute the T2 statistic, which follows an χ2 law whose quantiles are well known.


#### 4.1.4. Graphical Interpretation of the Test

Figure3(a) shows the correlation of values of K^-πr2 for two different values of r. Each point represents a simulation of a Poisson process. The plot should be imagined in a number of dimensions d equal to the number of r values. As K is a cumulative function, its values are highly autocorrelated. Figure 3(a) presents the results of simulations of a Poisson point process. Some are slightly aggregated (positive values); others are dispersed (negative values) due to stochasticity. Multiplying by Σ-1/2 yields values of T=Σ-1/2(K^-πr2) that are independent, centered, and of variance 1 (Figure 3(b)). We denote by T(r) each element of T and T=∥T∥.The circle’s radius is the square root of the 5% critical value of anχ2 distribution with 2 degrees of freedom. Point patterns corresponding to plots outside the circle are rejected. Thus, the test detects significant regularity of points (example not shown) as well as aggregation.Transforming correlatedK^ values into independent T whose squared norm follows an χ2 distribution relies on the exact, not asymptotic, variance matrix.


#### 4.1.5. Correcting Edge Effects for the Null Model Is a Better Choice

Classically, edge effects are corrected when estimatingK. Corrections assume unseen neighbors exist beyond the window’s limits and evaluate their number according to observed data inside the window. We prefer to calculate the bias of the null model and compare empirical, uncorrected values of K to their expected, biased values; see (3). We follow Gignoux et al. [24] who showed that testing data against CSR with nearest-neighbor functions was more powerful when ignoring edge effects (i.e., neither the actual point pattern nor Monte-Carlo simulations of the null hypothesis were corrected). Heuristically, correcting edge effects for each point means adding neighbors uniformly, reducing the power of the test against CSR.


### 4.2. Test of the Test

Although we use the exact variance matrix, we only proved asymptotical normality. This is a common issue of statistical tests; the confidence interval of an average value calculated from 30 repeated measures is usually evaluated assuming normality, only asymptotically proved.We evaluated the minimum number of points necessary to validate the level of the test. We simulated 10,000 realizations of a Poisson point process in a10×15 rectangle window and tested them. K^ was calculated at distances 1, 2, 3, 4, and 5. Intensity was chosen between 1/3 and 10, so that the expected number of points ranged between 50 and 1500.Figure4 shows the actual levels of rejections of the test (extreme intensities only are shown for readability). When points are few, the number of simulated patterns whose T value is above the critical value of χ2 at low risk levels (e.g., 1%) is a little more than the risk level. At the 5% risk level, we believe the test results are acceptable for practical purposes even with very few points. We expect 500 simulations to be rejected; Table 1 shows the rejection level is always under 6%.Table 1
Number of rejections of the null hypothesis (the point process is Poisson) out of 10,000 simulations of a homogenous point process in a rectangular 10 by 15 window. The significance level is 5%, so 500 simulations are expected to be rejected. The intensity varies from 1/3 to 10 so that the expected number of points varies from 50 to 1500, covering the range of usually-studied point patterns.
Expected number of points
50
100
150
300
750
1500
Number of rejections
592
587
543
537
524
543Figure 4
Actual rejection levels versus expected ones: ordinates are the quantiles of simulated Poisson point patterns whoseP values are below the value in abscissa. Curves are built from 10,000 simulations of homogenous Poisson point processes with different intensities (solid line: 50 points expected, dashed line: 1500 points). More simulations are rejected than should be when the number of points is low, but the discrepancy is less than 1%. With 1500 points, the quantiles of the test are very close to their expected values.We also wanted to evaluate the power of the test, that is to say, its ability to reject point patterns that are not completely random but hard to detect. Grabarnik and Chiu [30] proposed to use a mixture of Matérn and Strauss processes as a counterfactual. They tested the ability different statistics including Ripley’s K to distinguish them from a Poisson process. We followed them to draw a power test presented in Appendix B. Unsurprisingly, we find that our test’s power is very similar to that of K in Grabarnik and Chiu’s tests.


### 4.3. Choosing the Distance Vector

The choice ofr values (the vector of distances) is arbitrary. If the point process is actually a homogenous Poisson, results are identical whatever r is. Since it may not be, some rules should be followed; choosing the distances up to the expected range of interactions, with uniform steps, allows an “objective” analysis of the data [29], better than selecting values from the plots.TheT statistic is the sum of contributions of T(r) for all r values. T(r) are made independent by construction. Taking into account distances above the maximum range of interaction between points limits the power of the test since a fraction of the T(r) values are purely stochastic. This is a normal behavior for a goodness-of-fit test. When used on the whole distance range 0–250, Loosmore and Ford’s [8] test applied to the Tachigali example loses its power and returns a P value equal to 23.5%. In the same conditions, our test returns a P value equal to 6.3%; it appears to lose much less power when noisy data (there is no interaction between points at such distances) is introduced in the analysis. We chose to investigate distances up to 150 meters because we knew this was the possible range of interest.The last question is the number of distances considered. Too many values increase stochasticity relatively to the number of points (the number of new point pairs at each new value ofr gets more variable, if not often zero), while too few values do not allow to detect all scales of the pattern. In order to integrate all the information, steps between r values should be coherent with the processes to detect. 15 steps of 10 meters appear to be a correct way to test the structure of Tachigali. 5-meter steps are too small considering the density of the pattern (see Figure 1), and 20-meter steps are too large for the process we consider.


### 4.4. Application of the Test: A User’s Guide

We provide a test for a point pattern observed in a rectangular window against CSR. The code to run it with R is available as a supplementary material available online athttp://dx.doi.org/10.1155/2013/753475. The function Ktest accepts a point pattern object as defined in the spatstat package [31] and a vector of distances r. It returns a P value (the risk of error if CSR is rejected).Distances should be chosen up to the range of possible interactions, with equal intervals small enough to describe correctly the pattern, but too many steps if points are few. The maximum distanceK^(r) is computed must be less than or equal to half the width of the rectangle. This is a classical geometrical limitation, already faced by local edge-effect corrections [4] and [32, corrected up to half the length]. Rectangular windows only are supported.The test does not give information on what values ofr are responsible for its significance. Practically, in order not to lose usual references, a graphical representation of K or, better, its transformed function L, should be provided with local confidence intervals. If the number of points is great, the number of Monte-Carlo simulations can be reduced since these intervals are not used for the test.


## 4.1. Foundations of the Test

Many methods exist to test a point pattern against CSR [7, page 83:98], among which the relative variance [20, 21] or tests based on the nearest neighbors [22–24]. Tests based on the K function are particularly appealing because K^ provides data about the relative position of points at different scales, and the function simultaneously gives useful information about the point process.


### 4.1.1. The Distribution ofK^(r) under CSR Was Unknown

The classical, local test consists in comparing each observedK^(r) to the confidence interval of K^(r) obtained by Monte-Carlo simulations of the null model (which should be a homogenous Poisson point process, but is usually approximated by a binomial process for simplicity, artificially reducing variability). The null model is rejected at the chosen significance level, 5%, when the observed K^(r) is out of the corresponding confidence interval.To avoid simulations, approximate confidence intervals forK^(r) were proposed by Ripley [25], refuted by Koen [26] whose errors were finally corrected by Chiu [27]. All these confidence intervals were built on simulations.The variance ofK^(r) has been investigated early (see [5, page 58]). Asymptotic variance was calculated and asymptotic normality was proved, allowing calculating a confidence interval for K^(r), but the exact variance remains far from its asymptotic value for usual point sets [11]. We derived the exact variance in Appendix A.


### 4.1.2. TestingK^(r) along Many Values of r Is Not Correct

In our examples, we have 30 values ofK^(r). If we draw a point pattern in a Poisson process we can expect 5% of them, that is, 1 or 2 of them, to be out of the confidence interval. As a consequence, the local significance level of the test should be decreased dramatically to have a global significance level of 5%. Actually, K^(r) are highly correlated because K is a cumulative function; roughly speaking, most of K^(r) values come from that of the previous one (see Figure 3). This reduces the need for a correction but does not eliminate it completely [28]. Since no quantification of the correction is available, the local test is used, keeping in mind that the global significance level of the test is somehow higher than announced (see [7, page 456] for a discussion). Each of the local confidence interval values is correct but testing a curve made of 30 points against local confidence envelope is not [8].(a) Plot ofK^ minus its expectation πr2 in two dimensions (r=2 and r=5) for 500 simulations of a Poisson process of intensity ρ=5 drawn in a square window of size 10 (500 points on average). (b) Comparison of values of T(2) and T(5), after transformation. Around 25 simulations of the homogenous point process out of 500 lie out of the critical circle corresponding to T2>χ5%2(2) so they are rejected by the test.
(a)
(b)To address this issue, solutions have been proposed. Duranton and Overman [9] proposed a test consisting in eliminating simulated K^ vectors globally when one of their values is an extreme one. Global confidence intervals plotted in the figures are heuristic; they do not rely on any mathematical proof. They appear to be too conservative for Tachigali melinonii.


### 4.1.3. Goodness-of-Fit Tests Are a Solution

Goodness-of-fit (GoF) tests measure the discrepancy between the expected curve ofK under the null hypothesis and the actual curve. This value can be compared to its quantiles under CSR. Loosmore and Ford’s [8] test is a GoF test, already proposed by Diggle [4]. Its quantiles are not known so the test relies on Monte-Carlo simulations. Three GoF tests have been proposed by Heinrich [29] but all of them are asymptotic so none can be used with real data. Our test is very similar to Heinrich’s χ2 test, but as we derived the bias due to edge effects and the exact variance-covariance matrix of K^ under CSR, we were able to compute the T2 statistic, which follows an χ2 law whose quantiles are well known.


### 4.1.4. Graphical Interpretation of the Test

Figure3(a) shows the correlation of values of K^-πr2 for two different values of r. Each point represents a simulation of a Poisson process. The plot should be imagined in a number of dimensions d equal to the number of r values. As K is a cumulative function, its values are highly autocorrelated. Figure 3(a) presents the results of simulations of a Poisson point process. Some are slightly aggregated (positive values); others are dispersed (negative values) due to stochasticity. Multiplying by Σ-1/2 yields values of T=Σ-1/2(K^-πr2) that are independent, centered, and of variance 1 (Figure 3(b)). We denote by T(r) each element of T and T=∥T∥.The circle’s radius is the square root of the 5% critical value of anχ2 distribution with 2 degrees of freedom. Point patterns corresponding to plots outside the circle are rejected. Thus, the test detects significant regularity of points (example not shown) as well as aggregation.Transforming correlatedK^ values into independent T whose squared norm follows an χ2 distribution relies on the exact, not asymptotic, variance matrix.


### 4.1.5. Correcting Edge Effects for the Null Model Is a Better Choice

Classically, edge effects are corrected when estimatingK. Corrections assume unseen neighbors exist beyond the window’s limits and evaluate their number according to observed data inside the window. We prefer to calculate the bias of the null model and compare empirical, uncorrected values of K to their expected, biased values; see (3). We follow Gignoux et al. [24] who showed that testing data against CSR with nearest-neighbor functions was more powerful when ignoring edge effects (i.e., neither the actual point pattern nor Monte-Carlo simulations of the null hypothesis were corrected). Heuristically, correcting edge effects for each point means adding neighbors uniformly, reducing the power of the test against CSR.


## 4.1.1. The Distribution ofK^(r) under CSR Was Unknown

The classical, local test consists in comparing each observedK^(r) to the confidence interval of K^(r) obtained by Monte-Carlo simulations of the null model (which should be a homogenous Poisson point process, but is usually approximated by a binomial process for simplicity, artificially reducing variability). The null model is rejected at the chosen significance level, 5%, when the observed K^(r) is out of the corresponding confidence interval.To avoid simulations, approximate confidence intervals forK^(r) were proposed by Ripley [25], refuted by Koen [26] whose errors were finally corrected by Chiu [27]. All these confidence intervals were built on simulations.The variance ofK^(r) has been investigated early (see [5, page 58]). Asymptotic variance was calculated and asymptotic normality was proved, allowing calculating a confidence interval for K^(r), but the exact variance remains far from its asymptotic value for usual point sets [11]. We derived the exact variance in Appendix A.


## 4.1.2. TestingK^(r) along Many Values of r Is Not Correct

In our examples, we have 30 values ofK^(r). If we draw a point pattern in a Poisson process we can expect 5% of them, that is, 1 or 2 of them, to be out of the confidence interval. As a consequence, the local significance level of the test should be decreased dramatically to have a global significance level of 5%. Actually, K^(r) are highly correlated because K is a cumulative function; roughly speaking, most of K^(r) values come from that of the previous one (see Figure 3). This reduces the need for a correction but does not eliminate it completely [28]. Since no quantification of the correction is available, the local test is used, keeping in mind that the global significance level of the test is somehow higher than announced (see [7, page 456] for a discussion). Each of the local confidence interval values is correct but testing a curve made of 30 points against local confidence envelope is not [8].(a) Plot ofK^ minus its expectation πr2 in two dimensions (r=2 and r=5) for 500 simulations of a Poisson process of intensity ρ=5 drawn in a square window of size 10 (500 points on average). (b) Comparison of values of T(2) and T(5), after transformation. Around 25 simulations of the homogenous point process out of 500 lie out of the critical circle corresponding to T2>χ5%2(2) so they are rejected by the test.
(a)
(b)To address this issue, solutions have been proposed. Duranton and Overman [9] proposed a test consisting in eliminating simulated K^ vectors globally when one of their values is an extreme one. Global confidence intervals plotted in the figures are heuristic; they do not rely on any mathematical proof. They appear to be too conservative for Tachigali melinonii.


## 4.1.3. Goodness-of-Fit Tests Are a Solution

Goodness-of-fit (GoF) tests measure the discrepancy between the expected curve ofK under the null hypothesis and the actual curve. This value can be compared to its quantiles under CSR. Loosmore and Ford’s [8] test is a GoF test, already proposed by Diggle [4]. Its quantiles are not known so the test relies on Monte-Carlo simulations. Three GoF tests have been proposed by Heinrich [29] but all of them are asymptotic so none can be used with real data. Our test is very similar to Heinrich’s χ2 test, but as we derived the bias due to edge effects and the exact variance-covariance matrix of K^ under CSR, we were able to compute the T2 statistic, which follows an χ2 law whose quantiles are well known.


## 4.1.4. Graphical Interpretation of the Test

Figure3(a) shows the correlation of values of K^-πr2 for two different values of r. Each point represents a simulation of a Poisson process. The plot should be imagined in a number of dimensions d equal to the number of r values. As K is a cumulative function, its values are highly autocorrelated. Figure 3(a) presents the results of simulations of a Poisson point process. Some are slightly aggregated (positive values); others are dispersed (negative values) due to stochasticity. Multiplying by Σ-1/2 yields values of T=Σ-1/2(K^-πr2) that are independent, centered, and of variance 1 (Figure 3(b)). We denote by T(r) each element of T and T=∥T∥.The circle’s radius is the square root of the 5% critical value of anχ2 distribution with 2 degrees of freedom. Point patterns corresponding to plots outside the circle are rejected. Thus, the test detects significant regularity of points (example not shown) as well as aggregation.Transforming correlatedK^ values into independent T whose squared norm follows an χ2 distribution relies on the exact, not asymptotic, variance matrix.


## 4.1.5. Correcting Edge Effects for the Null Model Is a Better Choice

Classically, edge effects are corrected when estimatingK. Corrections assume unseen neighbors exist beyond the window’s limits and evaluate their number according to observed data inside the window. We prefer to calculate the bias of the null model and compare empirical, uncorrected values of K to their expected, biased values; see (3). We follow Gignoux et al. [24] who showed that testing data against CSR with nearest-neighbor functions was more powerful when ignoring edge effects (i.e., neither the actual point pattern nor Monte-Carlo simulations of the null hypothesis were corrected). Heuristically, correcting edge effects for each point means adding neighbors uniformly, reducing the power of the test against CSR.


## 4.2. Test of the Test

Although we use the exact variance matrix, we only proved asymptotical normality. This is a common issue of statistical tests; the confidence interval of an average value calculated from 30 repeated measures is usually evaluated assuming normality, only asymptotically proved.We evaluated the minimum number of points necessary to validate the level of the test. We simulated 10,000 realizations of a Poisson point process in a10×15 rectangle window and tested them. K^ was calculated at distances 1, 2, 3, 4, and 5. Intensity was chosen between 1/3 and 10, so that the expected number of points ranged between 50 and 1500.Figure4 shows the actual levels of rejections of the test (extreme intensities only are shown for readability). When points are few, the number of simulated patterns whose T value is above the critical value of χ2 at low risk levels (e.g., 1%) is a little more than the risk level. At the 5% risk level, we believe the test results are acceptable for practical purposes even with very few points. We expect 500 simulations to be rejected; Table 1 shows the rejection level is always under 6%.Table 1
Number of rejections of the null hypothesis (the point process is Poisson) out of 10,000 simulations of a homogenous point process in a rectangular 10 by 15 window. The significance level is 5%, so 500 simulations are expected to be rejected. The intensity varies from 1/3 to 10 so that the expected number of points varies from 50 to 1500, covering the range of usually-studied point patterns.
Expected number of points
50
100
150
300
750
1500
Number of rejections
592
587
543
537
524
543Figure 4
Actual rejection levels versus expected ones: ordinates are the quantiles of simulated Poisson point patterns whoseP values are below the value in abscissa. Curves are built from 10,000 simulations of homogenous Poisson point processes with different intensities (solid line: 50 points expected, dashed line: 1500 points). More simulations are rejected than should be when the number of points is low, but the discrepancy is less than 1%. With 1500 points, the quantiles of the test are very close to their expected values.We also wanted to evaluate the power of the test, that is to say, its ability to reject point patterns that are not completely random but hard to detect. Grabarnik and Chiu [30] proposed to use a mixture of Matérn and Strauss processes as a counterfactual. They tested the ability different statistics including Ripley’s K to distinguish them from a Poisson process. We followed them to draw a power test presented in Appendix B. Unsurprisingly, we find that our test’s power is very similar to that of K in Grabarnik and Chiu’s tests.


## 4.3. Choosing the Distance Vector

The choice ofr values (the vector of distances) is arbitrary. If the point process is actually a homogenous Poisson, results are identical whatever r is. Since it may not be, some rules should be followed; choosing the distances up to the expected range of interactions, with uniform steps, allows an “objective” analysis of the data [29], better than selecting values from the plots.TheT statistic is the sum of contributions of T(r) for all r values. T(r) are made independent by construction. Taking into account distances above the maximum range of interaction between points limits the power of the test since a fraction of the T(r) values are purely stochastic. This is a normal behavior for a goodness-of-fit test. When used on the whole distance range 0–250, Loosmore and Ford’s [8] test applied to the Tachigali example loses its power and returns a P value equal to 23.5%. In the same conditions, our test returns a P value equal to 6.3%; it appears to lose much less power when noisy data (there is no interaction between points at such distances) is introduced in the analysis. We chose to investigate distances up to 150 meters because we knew this was the possible range of interest.The last question is the number of distances considered. Too many values increase stochasticity relatively to the number of points (the number of new point pairs at each new value ofr gets more variable, if not often zero), while too few values do not allow to detect all scales of the pattern. In order to integrate all the information, steps between r values should be coherent with the processes to detect. 15 steps of 10 meters appear to be a correct way to test the structure of Tachigali. 5-meter steps are too small considering the density of the pattern (see Figure 1), and 20-meter steps are too large for the process we consider.


## 4.4. Application of the Test: A User’s Guide

We provide a test for a point pattern observed in a rectangular window against CSR. The code to run it with R is available as a supplementary material available online athttp://dx.doi.org/10.1155/2013/753475. The function Ktest accepts a point pattern object as defined in the spatstat package [31] and a vector of distances r. It returns a P value (the risk of error if CSR is rejected).Distances should be chosen up to the range of possible interactions, with equal intervals small enough to describe correctly the pattern, but too many steps if points are few. The maximum distanceK^(r) is computed must be less than or equal to half the width of the rectangle. This is a classical geometrical limitation, already faced by local edge-effect corrections [4] and [32, corrected up to half the length]. Rectangular windows only are supported.The test does not give information on what values ofr are responsible for its significance. Practically, in order not to lose usual references, a graphical representation of K or, better, its transformed function L, should be provided with local confidence intervals. If the number of points is great, the number of Monte-Carlo simulations can be reduced since these intervals are not used for the test.


## 5. Conclusion

Characterizing the spatial structure of a dataset representing the location of plants in an experimental plot is a common task for ecologists [33]. We provide a rigorous statistical test to reject the null hypothesis that K values of an observed point pattern in a rectangle window are that of a realization of a homogenous Poisson point process. This test replaces advantageously the classical Monte-Carlo one. It will rather complete it in practical applications since Monte-Carlo simulations provide useful local information on the point process.The test is ready to use with the provided R code to be found in the electronic appendices.Future work includes both supporting more complex shapes, probably triangle assemblies following Pélissier and Goreaud [34], and other point processes as null hypotheses. Although it is still limited to the simplest applications, we believe this test is an important step towards more rigorous spatial statistics, based on analytical results rather than simulations.



---

*Source: 753475-2013-04-14.xml*