ads Package for R : A Fast Unbiased Implementation of the K -function Family for Studying Spatial Point Patterns in Irregular-Shaped Sampling Windows

ads is an R package that performs multi-scale spatial point pattern analyses through methods derived from Ripley’s K -function. These methods apply to univariate, multivariate or marked point data mapped in a rectangular, circular or irregular-shaped sampling window. Speciﬁc tests of statistical signiﬁcance based on Monte Carlo simulations are associated to these methods. The main features of ads is to call fast C subroutines for computing Ripley’s unbiased local correction of edge eﬀects for various sampling window conﬁgurations and for performing Monte Carlo simulations. It thus allows one to analyze large datasets and to compute robust conﬁdence envelopes. This paper is an introduction to ads version 1.5, focusing on its complementarity with the other R packages for spatial point pattern analysis, and on recent original developments towards the introduction of multivariate functions for analyzing spatial pattern of species diversity.


Introduction
ads is an R package for spatial analysis of mapped data based on second-order multi-scale analyses of spatial point patterns derived from Ripley's (1977) K-function (the K-function family).Initially implemented for forest ecologists who often need to analyze large naturally heterogeneous tree maps, it is based on C subroutines that include geometrical functions to perform unbiased isotropic correction of edge effects for sampling windows of any shape (i.e., rectangular, circular, polygonal or with holes), as well as procedures to fast computation of Though spatial only allows a rectangular sampling window and splancs doesn't allow a polygon with holes, the four packages return, in all comparable cases, exactly the same numerical results for K(r) (see replication file).Similar differences in performance were obtained for the other K-functions listed in Table 1.robust confidence envelopes of basic spatial null hypotheses from a large number of Monte Carlo simulations.It therefore combines efficiency of historical packages for point pattern analysis that interface foreign languages, i.e., spatial (Venables and Ripley 2002) or splancs (Rowlingson and Diggle 1993), with the flexibility of the more recent spatstat (Baddeley and Turner 2005), especially for data manipulation, point pattern modeling and simulation.As an illustration, Figure 1 shows that in terms of run time 1 , ads largely outperforms the other R packages, except splancs for a single polygonal sampling window, probably because of two different implementations of the isotropic edge effects correction (see Agterberg 1994;Goreaud and Pélissier 1999).
ads: A Fast Unbiased Implementation of the K-function Family in R variable (e.g., tree stem diameter), so defining various types of point patterns (i.e., univariate, multivariate or marked).The computational functions automatically recognize these objects and their types, and call accordingly the appropriate C subroutines.Version 1.5 of ads computes the most classical members of the K-function family, as in particular does spatstat, but also more specific functions for the spatial analysis of species diversity from multivariate point patterns, which, from our knowledge, do not exist in any other R package (Table 1).

Data preparation
In ads, a spatial point pattern is defined as a set of point coordinates in a finite rectangular, circular or irregular-shaped two-dimensional study domain.The study domain is represented by an object of the class "swin" (sampling window), to which point coordinates are attached along with optional attributes (marks) to create an object of the class "spp" (spatial point pattern).All computational functions in ads use an "spp" object as mandatory input argument.Specific print, summary and plot methods apply to "swin" and "spp" objects.
A special function owin2swin allows converting spatstat observational windows ("owin" objects) into "swin" objects, so that the extended facilities of spatstat for data preparation are also available to ads users.

Sampling window definition
Function swin creates an object of the class "swin", which is of "simple" or "complex" type.
A simple sampling window is either: Rectangular, defined as a vector of length 4 giving coordinates (xmin, ymin) and (xmax, ymax) of the origin and the opposite corner of the sampling window, e.g., for a square of 110 × 90: R> rect <-swin(window = c(0, 0, 110, 90)) Circular, defined as a vector of length 3 giving coordinates (x0, y0) of the centre and the radius r0 of the sampling window, e.g., for a disc of radius 30 centered at (50, 50): R> circ <-swin(window = c(50, 50, 30)) To comply with the method of edge effects correction implemented in ads (see Goreaud and Pélissier 1999), a complex sampling window type is defined by removing triangular surfaces from an initial sampling window of simple shape (rectangular or circular).The triangles may be removed near the boundary of a rectangular window in order to design a polygonal sampling window or as "holes" when they do not connect with the outer sampling window boundary.

Point pattern definition
Function spp creates an object of the class "spp", defined from an "swin" object to which are attached point coordinates along with some optional attributes, such as categorical or numerical marks, so representing either: Univariate point pattern: R> x <-runif(100, 0, 110) R> y <-runif(100, 0, 90) R> unispp <-spp(x = x, y = y, window = rect) Multivariate point pattern, when a categorical mark is attached to each point of the pattern through optional argument marks: R> sp <-as.factor(c(rep("sp1",50), rep("sp2", 30), rep("sp3", 20))) R> multispp <-spp(x = x, y = y, window = rect, marks = sp) Marked point pattern, when a numerical mark is attached to each point of the pattern through optional argument marks: R> var <-sample(100)/10 R> markspp <-spp(x = x, y = y, window = poly, marks = var) Function spp automatically segregates points located outside the limits of the sampling window so that they are ignored in computational functions.For instance, when the sampling window is of "complex" type, spp calls function inside.swin to segregate the points located inside the triangles.Similarly, attaching the same set of points to a resized sampling window creates a new "spp" object (Figure 2).A specific function ppp2spp converts "ppp" planar point pattern objects from spatstat to "spp" objects.

Data analysis
Package ads basically performs second-order neighborhood analyses derived from Ripley's (1977) K-function for univariate, multivariate or marked point patterns (the K-function family).These functions use "spp" objects as input argument and return distance-dependent summary statistics stored as objects of the class "fads".Ancillary functions also compute local values of first-and second-order densities stored as objects of the class "vads".There exist print and plot methods for both these classes of objects.

Implementation principles
In ads all univariate functions of second-order neighborhood analysis are estimated following the same principle: the expected number of neighbors within a distance r from an arbitrary point of the pattern is computed as its mean over all points by N (r) = N i=1 N j =i k ij /N , where N is the number of points of the pattern, k ij = 0 if d(i, j) > r, else k ij = 2πr/P ij , with P ij the perimeter of the circle centered on i and passing through j, which is inside the sampling window.It follows that when d(i, j) ≤ r, k ij = 1 if point i is at a distance smaller than r to the sampling window boundary, and k ij > 1 otherwise.This corresponds to Ripley's (1977) unbiased correction of edge effects (also called isotropic correction) for the computation of which explicit geometrical formulas are implemented in ads to apply to simple or complex sampling windows as defined above (Goreaud and Pélissier 1999).For computational efficiency, values of N (r) are computed for t successive values of r equally spaced by a distance interval of d, with t an integer in [1, tmax], so that r = td.Function kfun computes various common summary statistics derived from this basic computation: The local neighbor density function n(r) = N (r)/πr 2 is an area standardization with an expectation of λ = N/A for all r under the hypothesis of Complete Spatial Randomness (CSR; Diggle 1983), with A the sampling window area.Ripley's (1977) function K(r) = N (r)/ λ with an expectation of πr 2 under CSR.
] with an expectation of 1 under CSR, is an estimator of the pair density function (Stoyan et al. 1987) giving the expected number of neighbors within an annulus between r and r − d, so that an estimator of the O-ring statistics (Wiegand and Moloney 2004) is Ô(r) = λĝ(r).

Monte Carlo simulations
As the theoretical distributions of these estimators are unknown, Monte Carlo simulations are used to build test statistics and confidence envelopes of specified null hypotheses (Besag and Diggle 1977).The method consists of simulating a large number (Nsim) of realizations of a spatial point process representing the null hypothesis, for instance a homogeneous Poisson process for representing CSR hypothesis (the only null hypothesis currently allowed in kfun).Monte Carlo simulations of CSR hypothesis (run time 1 = 1.686 sec).BP2 is an "spp" object as defined in the replication file and corresponding to the central pattern in Figure 2. L(r) shows a significant negative deviation within a neighborhood distance of 1 to 7m, indicating regularity of the pattern.
Because of edge effects, particularly in complex sampling windows, the process is simulated in the same sampling window and with the same number of points as the observed point pattern.The K-functions are then estimated for each realization of the simulated process.Strictly speaking, simulations should be independent at each distance value, but in practice the bias introduced when the functions are computed over all the range of r distances at each simulation is negligible, at least when the number of simulations is large enough (Goreaud 2000).
At a given r, a local test of the null hypothesis is built by comparing the absolute deviation of estimated values to the expected theoretical values, obtained for the observed point pattern on the one hand, and for the different realizations of the null hypothesis on the other hand (Barot and Gignoux 1999).For the univariate estimators above, this absolute deviation is: At each r, the rate of simulations that lead to an observed deviation lower than or equal to the simulated one (rejection of the null hypothesis) gives the local significance level of the test (P -value).One can also build a local bilateral confidence envelope for a given type 1 error risk of 2α, by taking as lower and upper limits at each r, the α th and (100 − α) th percentiles of the distribution of the simulated values, respectively.When the observed value of a function at a given r is outside the confidence envelope limits, the spatial pattern is significantly different at the 2α risk level from the one expected under the null hypothesis (Figure 3).
ads: A Fast Unbiased Implementation of the K-function Family in R

Bivariate functions
The bivariate K 12 -function proposed by Lotwick and Silverman (1982) is an extension of Ripley's K-function to analyze spatial patterns of points bearing a two-level categorical mark.
It is also known as the intertype function (Diggle 1983), which characterizes the spatial interaction between points of two different types (such as trees of two different species) located in the same study domain.In ads, bivariate functions are computed from an estimate of the expected number of type 2 points located within a distance r of an arbitrary type 1 point of the pattern, by N12 (r where N 1 and N 2 are the number of type 1 and type 2 points of the pattern, respectively, and k ij is as in the univariate case, including the isotropic correction of edge effects, but with i and j representing the points of type 1 and 2, respectively.Function k12fun computes the following: n12 (r) = N12 (r)/πr 2 ; K12 (r) = N12 (r)/ λ2 where λ2 = N 2 /A, and A is the sampling window area; Here also, P -values and confidence envelope limits are computed at each r from observed and simulated absolute deviations between the empirical and theoretical values expected under a given null hypothesis.For the bivariate case, the null hypothesis of no interaction between the two types of points correspond either to (Goreaud and Pélissier 2003): A hypothesis of random labeling (RL) when the spatial pattern of type 1 and type 2 points result from a single completely random process affecting the points a posteriori (for instance a disease attack within a tree population).In this case, expectations of the bivariate functions are: n 12 (r) = λ; K 12 (r) = K(r); L 12 (r) = L(r); g 12 (r) = g(r).This hypothesis is tested conditionally to the spatial pattern of the whole population (i.e., without type distinction) by reallocating the types at random amongst the points of the pattern whose location is kept unchanged.
A hypothesis of population independence (PI) when the spatial patterns of type 1 and type 2 points result from different processes (for instance two tree species with their own dispersal process), with expectations: n 12 (r) = λ 2 ; K 12 (r) = πr 2 ; L 12 (r) = 0; g 12 (r) = 1.This hypothesis is tested conditionally to the spatial pattern of each population, classically by shifting type 1 points by a random vector over a torus, while the pattern of type 2 points is kept unchanged (PI-tor), as proposed by Lotwick and Silverman (1982).In case of a non-rectangular sampling window, the torus connects the top and bottom edges of the rectangular frame enclosing the sampling window so that some of the type 1 points can be shifted outside the limits of the actual sampling window and will be thus ignored in computation.This however is not expected to bias K 12 (r) estimations, since type 1 points are the focal points for which we estimate the number of type 2 neighbors.Problems may however arise in extreme cases when the number of type 1 points ignored is too large (e.g., when the enclosing rectangle is too large with respect to the actual polygonal window), so that the remainder doesn't allow a correct estimation of the mean number of type 2 neighbors (Figure 4).As an alternative, the Figure 4: Bivariate functions estimated for "beech" and "oak" species from dataset BPoirier (left) using k12fun with a 99% local confidence envelope obtained from 1000 Monte Carlo simulations of population independence hypothesis (PI-tor; top panel; run time 1 = 0.610 sec) or random labeling hypothesis (RL; bottom panel; run time= 0.993 sec).Note that in this example (2 different species populations) RL is probably not an ecologically sound null hypothesis (dataset Allogny provides a more appropriate example).It however illustrates the two different theoretical expectations (red lines) and confidence envelopes (green lines) under PI and RL null hypotheses.BP4 is an "spp" object as defined in the replication file.
mimetic point process (Goreaud, Loussier, Ngo Bieng, and Allain 2004) introduced in Section 3.6 below can be used to replicate the pattern of type 1 points, keeping here also the pattern of type 2 points unchanged (PI-mim).Here also it is recommended for efficiency to avoid defining a too large enclosing rectangle because the points are first generated within the rectangle and then retained only if they do not fall within a triangle.This procedure, though more robust, is however computationally intensive.

Multivariate functions
Multivariate functions apply to patterns of points bearing more than two categorical marks, such as, for instance, trees in a mixed-species forest stand.They are basically of two different types in ads: simple wrapper functions to display bivariate functions in a practical matrix-like format, or more advanced functions to analyze and test spatial pattern of species diversity.

Wrapper functions for multivariate point patterns
Function kp.fun computes a set of K 12 -functions between all possible marks p and the other marks grouped together in a multivariate spatial pattern, while function kpqfun computes, ads: A Fast Unbiased Implementation of the K-function Family in R for all possible pairs of marks (p, q), a set of K-and K 12 -functions, when p = q and p = q, respectively.It is however not possible to compute confidence envelopes directly from these functions.Specific plot methods display the results in a matrix-like format.

Spatial pattern of species diversity
The Simpson's index (Simpson 1949) of species diversity gives the probability that a randomly selected pair of individuals in a sample has two different species.Its unbiased estimator is: , where S is the total number of species, N p the number of individuals of species p and N = S p=1 N p .Shimatani (2001) proposed functions of multivariate spatial point pattern analysis as distance-dependent extensions of Simpson's index that he demonstrated to be estimable by combining univariate K-function estimators (see also Eckel, Fleischer, Grabarnik, and Schmidt 2008): p Kp (r)/ λ2 K(r), which is an estimator of α(r) of Shimatani (2001).
In the above equations K(r) and K p (r) -respectively g(r) and g p (r) -are simply the univariate K-functions -respectively g-functions -computed from the spatial pattern of all species pooled together (no type distinction) and of species p, respectively.KS (r) is the mean over all points of the pattern of Simpson's diversity within a neighborhood distance r, which conceptually corresponds to the notion of a distance-dependent measure of α-diversity sensu Whittaker (1972).However, g S (r) is hard to conceptualize as proposed by Shimatani (2001), as a distance-dependent version of a β-diversity measure sensu Whittaker (1972) (i.e., as a dissimilarity between two samples), but more simply gives an estimate of Simpson's diversity in an annulus between r and r − d.It follows that under the null hypothesis of a perfectlymixed species assemblage KS (r) = ĝS (r) = D or equivalently KS (r)/ D = ĝS (r)/ D = 1.In ads, function ksfun computes both functions as wrapper functions of kfun as introduced in Section 3.1.The null hypothesis can be tested either by a generalization of the random labeling procedure when the marking process is considered to have affected the points a posteriori to the spatial location process (see Section 3.2), or by a random placement procedure (RP) simulating random spatial patterns for each species independently (Shen et al. 2009), an approach more compatible with the biological hypothesis of a species assemblage in absence of any inter-and intra-specific interactions.
A more general diversity index that measures the expected difference between individuals of a randomly selected pair in a sample is Rao's (1982) quadratic entropy, for which an unbiased estimator is: ĤD = S p=1 S q=1 d pq N p N q /N (N − 1), where N p and N q are the numbers of individuals of species p and q in a sample of size N , respectively, and d pq measures a phylogenetic or functional Euclidean distance between these species (Pavoine, Ollier, and Pontier 2005).It is noteworthy that when d pq = 1 for all p = q and 0 otherwise, H D reduces to Simpson's D (see above).As this index requires considering all pairs of non-conspecific points, it can be envisioned as a combination of univariate and bivariate K-function estimators that de facto integrates the isotropic correction of edge effects: d pq λp λq Kpq (r)/ λ2 K(r) KR (r) is the mean over all points of the pattern of the quadratic entropy within a neighborhood distance r.We can also define g R (r), the quadratic entropy in an annulus between r and r − d as: Under the null hypothesis of a perfectly-mixed species assemblage KR (r) = ĝR (r) = ĤD or equivalently KR (r)/ ĤD = ĝR (r)/ ĤD = 1, tested, as for K S (r), by either a general random labeling or a random placement procedure.In ads, function krfun computes both functions as wrapper functions of kfun and k12fun introduced above.When d pq = 1 for all p = q and 0 otherwise, K R (r) and g R (r) are alternative implementations of K S (r) and g S (r), respectively.This thus provides an opportunity for testing the highly meaningful ecological hypothesis of species equivalence (SE) based on d pq (Shen et al. 2013).
Under SE hypothesis we expect K R (r)/H D = K S (r)/D -respectively g R (r)/H D = g S (r)/D -, which can be tested using a Monte Carlo procedure shuffling the between-species distances by permuting simultaneously the rows and columns in d pq .When d pq is a cophenetic distance matrix, this is equivalent to permuting the tips of a hierarchical (for instance, phylogenetic) tree (Hardy 2008) The advantage here is that edge effects cancel out between numerator and denominator, so that an efficient implementation for a sampling window of any shape doesn't require correcting for edge effects (i.e., k ij = 1 in g pq (r) and K pq (r) whatever the relative locations of point i of species p and point j of species q with respect to the sampling window boundary; see Section 3.2).Both functions quantify the phylogenetic/functional spatial structure of a community conditionally to the multi-species spatial pattern (see Shen et al. 2013), with in both cases, a theoretical expected value of 1 at all r under the species equivalence hypothesis.

Marked functions
The K m -function analyses the spatial structure of correlations between values of a quantitative variable borne by points of a marked pattern.The version implemented in ads is simply a correlogram corrected for edge effects using Ripley's istropic method: , where X is a random variable defining the marks at points i and j and N (r) is the mean number of pairs of points that are neighbors within distance r.P15 is an "spp" object as defined in replication file, with a between-species distance matrix corresponding to a cophenetic distance based on APG III phylogeny (Chase and Reveal 2009).This example shows a significant negative deviation of Simpson's diversity from the RP hypothesis from about 5 m (more conspecific neighbors than expected for the entire plot) and of Rao's diversity from the SE hypothesis (more closely related neighbors than expected) in the range 5-20m.
An unbiased estimator of this function is (Goreaud 2000): where x i and x j are the values of X borne by the neighboring points i and j, k ij is as in the univariate function, and x is the mean of X over the N points of the pattern.K m (r) varies between −1 and 1 and has an expectation of 0 when the marks are totally uncorrelated.
In ads, function kmfun also computes the derivative of K m (r) (or pair correlation function; Penttinen et al. (1992)) that gives the correlation of marks within an annulus between r and r − d: Like K m (r), g m (r) has an expectation of 0 in absence of mark correlation.For both functions local confidence envelops and P -values of departure from the null hypothesis of an absence of correlation between marks is tested by reallocating at random the values of X over all points of the pattern (Independent Marking), keeping the spatial location of points unchanged (Figure 6).Two specific applications of this function in the context of forest studies can be found in Oddou-Muratorio, Demesure-Musch, Pélissier, and Gouyon (2004) and Madelaine et al. (2007).

Local density functions
Ancillary functions computing first-and second-order density values for a range of neighborhood distances are also available in ads (Pélissier and Goreaud 2001).The second-order local density function, kval, computes a local version of Ripley's univariate functions as proposed in Getis and Franklin (1987).Basically the function computes, for each point i of the pattern, n i (r) = N i (r)/πr 2 , where N i (r) is the number of neighbors within distance r of point i corrected for edge effects, which has an expectation of (N − 1)/A under CSR, with N the total number of points of the pattern and A the sampling window area.It also returns the classical univariate transformations, i.e., K i (r), L i (r) and g i (r) (see Section 3.1).Function k12val is the bivariate extension, which gives n i2 (r), the local density of neighbors of type 2 within a distance r of each i point of type 1. Consistently with this approach, we also introduced the first-order local density function, dval, which computes values of n(x, y) = N (r)/πr 2 at each node (x, y) of a systematic grid covering the sampling window, where N (r) is the number of points of the pattern within a distance r of a node, to which Ripley's isotropic correction of edge effects is applied.Specific summary and plot methods exist for these functions that are useful for exploratory data analysis.2) using a depletion-replacement procedure minimizing a global cost based on the difference between the observed and simulated Lfunctions.kBP1 is a "fads" object returned by function kfun.In this example, 476 depletionreplacement events were needed to reach minimum global cost (run time 1 = 1.432 sec).

Spatial point pattern replication
Spatial point patterns are realizations of spatial point processes.Goreaud et al. (2004) developed a stepwise depletion-replacement procedure to generate different realizations of an observed point pattern using a mimetic point process that minimizes the following global cost: N i=1 L obs (r) − L sim (r) 2 , where L obs is the univariate L-function computed for an observed point pattern and L sim is the L-function computed at each step of the depletionreplacement process.Function mimetic implemented in ads initially simulates a completely random spatial pattern with same intensity as the observed pattern.The procedure makes the global cost function slowly decrease and the process stops when it converges to a minimum, i.e., when a given number of depletion-replacement events (50 by default) do not make the cost function significantly decrease (Figure 7).The function works with a sampling window of any shape.

Conclusion and perspectives
Package ads has been developed in the late 90's for the requirements of forest ecologists, initially as a standalone C application within a special section of ADE-4 software (Thioulouse, Chessel, Dolédec, and Olivier 1997) -now package ade4 for R (Dray and Dufour 2007).The core C code used for the implementation of the geometrical functions of edge effects correction was written by Goreaud (2000) in the framework of his PhD thesis, based on triangle geometry (Goreaud and Pélissier 1999).The original C code was ported to R in 2007.At this time the paper by Agterberg (1994), that presents the geometrical principles behind the method of edge effects correction used in splancs, and which proved faster for polygonal sampling windows than the one used in ads (see Figure 1), was unknown by us.There is consequently an avenue of improvement of ads by integrating the two approaches on the basis of splancs fortran code ported to R by Bivand and Gebhardt (2000).For similar historical reasons, the sampling window ("swin") and spatial point pattern ("spp") objects used in ads are similar but not exactly the same to the ones used in spatstat.Though we developed special functions, owin2swin and ppp2spp, for compatibility with spatstat objects, much remain to be done to allow users to shift more easily from one package to the other.On the one hand ads proved to be always much faster than spatstat, a useful property for one to deal with large datasets and robust confidence envelopes (i.e., based on a large number of Monte Carlo simulations), while on the other hand, spatstat is more flexible for data manipulation and offers a larger panel of different spatial functions, not only limited to the K-function family.Finally the recent developments introduced in ads for the spatial analysis of species diversity, especially the ones based on Rao's (1982) quadratic entropy, do not seem to exist in any other R package.There is thus here an opportunity for the development of new such approaches integrating species diversity and spatial analyses, for instance to study the spatial structure of functional or phylogenetic species diversity in the well-mastered framework of the spatial point processes (see Shen et al. 2013).When the distance between species is based on a phylogenetic tree, various null hypotheses can be tested thanks to specific, more or less restricted, randomization procedures, whose implementation could be quite challenging (see Hardy 2008).Perspectives also exists to extend the mimetic point process for replicating multivariate point patterns, as introduced in Goreaud et al. (2004).# Creating point pattern objects for ads spp.rect <-spp(ppp.rect$x,y = ppp.rect$y,owin2swin(rect)) spp.poly <-spp(ppp.poly$x,y = ppp.poly$y,owin2swin(poly)) spp.hole <-spp(ppp.hole$x,y = ppp.hole$y,owin2swin(hole)) # Creating point pattern object for spatial (only rectangle allowed) library("spatial") pp.rect <-list(x = ppp.rect$x,y = ppp.rect$y,area = ppregion(0, 100, 0 , 100)) # Mofifying the Kenvl function to introduce variable k as in Kfn Kenvl2 <-function (fs, k, nsim, ...) { dot.expression <-as.expression(substitute(...)) h <-Kfn(pp = eval(dot.expression),fs, k) hx <-h$x hu <-h$y hl <-h$y ha <-h$y^2 for (i in 2:nsim) { h <-Kfn(pp = eval(dot.expression),fs, k)$y hu <-pmax(hu, h) hl <-pmin(hl, h) ha <-ha + h^2 } list(x = hx, lower = hl, upper = hu, aver = sqrt(ha/nsim), call = match.call()))), triangles = BPoirier$tri3, marks=BPoirier$species) plot(BP4) k12BP4pi <-k12fun(BP4, 25, 1, nsim = 1000, marks = c("beech", "oak")) plot(k12BP4pi) k12BP4rl <-k12fun(BP4, 25, 1, H0="rl", nsim = 1000, marks = c("beech", "oak")) plot( k12BP4rl

Figure 1 :
Figure 1: Computational run time 1 of four R packages to estimate Ripley's K(r) for a simulated point pattern of 1000 points in three different sampling windows.Monte Carlo simulations are here used for testing spatial patterns against Complete Spatial Randomness (CSR).Though spatial only allows a rectangular sampling window and splancs doesn't allow a polygon with holes, the four packages return, in all comparable cases, exactly the same numerical results for K(r) (see replication file).Similar differences in performance were obtained for the other K-functions listed in Table1.

Figure 2 :
Figure 2: Plots of "spp" objects from dataset BPoirier with resized sampling windows ("swin" objects) attached to the same set of point coordinates.Points located outside the sampling window (in red color) are ignored by ads computational functions.

Figure 3 :
Figure3: Univariate functions estimated for BPoirier dataset with kfun function computed from 1 to 25m by 1-m distance steps and a 99% local confidence envelope obtained from 1000 Monte Carlo simulations of CSR hypothesis (run time 1 = 1.686 sec).BP2 is an "spp" object as defined in the replication file and corresponding to the central pattern in Figure2.L(r) shows a significant negative deviation within a neighborhood distance of 1 to 7m, indicating regularity of the pattern.
= BP4, upto = 20, by = 1, nsim = 1000, marks = c("beech", "oak")) obs theo (PI−tor) 99 % CI of PI−= BP4, upto = 20, by = 1, nsim = 1000, H0 = "rl", marks = c("beech", "oak") . Shen et al. (2013) demonstrated powerfulness of this approach for testing ecological hypotheses of phylogenetic spatial structure based on a function they called k d (r) and which is actually very close to the ratio of g R (r)/H D on g S (r)/D.Thus, Shen's et al. function should have been better quoted as g d (r) in order to keep, for consistency, the notation K d (r) for the cumulative version corresponding to the ratio of K R (r)/H D on K S (r)/D.In ads, function kdfun computes:

Figure 5
Figure 5 gives an example of analysis of the pattern of species diversity for a tropical forest plot of 250 × 250 m with 4128 trees of 332 different species (dataset Paracou15; Gourlet-Fleury, Guehl, and Laroussinie 2004).

Figure 5 :
Figure5: Multivariate functions of species diversity estimated for dataset Paracou15 (left) using ksfun (top panel) and kdfun (bottom panel) with a 99% local confidence envelope obtained from 500 Monte Carlo simulations of random placement hypothesis (RP; top panel; run time 1 = 400.735sec) or species equivalence hypothesis (SE; bottom panel; run time= 151.145 sec).P15 is an "spp" object as defined in replication file, with a between-species distance matrix corresponding to a cophenetic distance based on APG III phylogeny(Chase and Reveal 2009).This example shows a significant negative deviation of Simpson's diversity from the RP hypothesis from about 5 m (more conspecific neighbors than expected for the entire plot) and of Rao's diversity from the SE hypothesis (more closely related neighbors than expected) in the range 5-20m.

FPFigure 6 :
Figure6: Spatial pattern of tree height from dataset finpines (left) along with the univariate L-function with confidence envelope of CSR (top panel) and the marked K m -function with confidence envelope of independent marking hypothesis (IM) obtained from 500 Monte Carlo simulations (bottom panel; run time 1 = 0.367 sec).This example shows that while saplings are significantly clustered in space, their height is spatially uncorrelated.

Figure 7 :
Figure7: Diagnostic plot of the mimetic point process that replicates the observed BPoirier univariate point pattern (left panel in Figure2) using a depletion-replacement procedure minimizing a global cost based on the difference between the observed and simulated Lfunctions.kBP1 is a "fads" object returned by function kfun.In this example, 476 depletionreplacement events were needed to reach minimum global cost (run time 1 = 1.432 sec).

Table 1 :
Computational functions of point pattern analysis implemented in ads with equivalent functions in other R packages. 1 rectangular (rect), circular (circ), polygonal (poly), polygonal with holes (hole); 2 Complete Spatial Randomness hypothesis; 3 limited to Poisson Cluster Process