## Multiscale second-order neighbourhood analysis of an univariate spatial point pattern

### Description

Computes estimates of Ripley's K-function and associated neighbourhood functions from an univariate spatial point pattern in a simple (rectangular or circular) or complex sampling window. Computes optionally local confidence limits of the functions under the null hypothesis of Complete Spatial Randomness (see Details).

### Usage

```kfun(p, upto, by, nsim=0, prec=0.01, alpha=0.01)
```

### Arguments

 `p ` a `"spp"` object defining a spatial point pattern in a given sampling window (see `spp`). `upto ` maximum radius of the sample circles (see Details). `by ` interval length between successive sample circles radii (see Details). `nsim ` number of Monte Carlo simulations to estimate local confidence limits of the null hypothesis of complete spatial randomness (CSR) (see Details). By default `nsim=0`, so that no confidence limits are computed. `prec ` if `nsim>0`, precision of points' coordinates generated during simulations. By default `prec=0.01`. `alpha ` if `nsim>0`, significant level of the confidence limits. By default α=0.01.

### Details

Function `kfun` computes Ripley's K(r) function of second-order neighbourhood analysis and the associated functions g(r), n(r) and L(r).

For a homogeneous isotropic point process of intensity λ, Ripley (1977) showed that the second-order property could be characterized by a function K(r), so that the expected number of neighbours within a distance r of an arbitrary point of the pattern is: N(r) = λ*K(r).

K(r) is a intensity standardization of N(r), which has an expectation of π*r^2 under the null hypothesis of CSR: K(r) = N(r)/λ.

n(r) is an area standardization of N(r), which has an expectation of λ under the null hypothesis of CSR: n(r) = N(r)/(π*r^2), where π*r^2 is the area of the disc of radius r.

L(r) is a linearized version of K(r) (Besag 1977), which has an expectation of 0 under the null hypothesis of CSR: L(r) = √(K(r)/π)-r. L(r) becomes positive when the pattern tends to clustering and negative when it tends to regularity.

g(r) is the derivative of K(r) or pair density function (Stoyan et al. 1987), so that the expected number of neighbours at a distance r of an arbitrary point of the pattern (i.e. within an annuli between two successive circles with radii r and r-by) is: O(r) = λ*g(r).

The program introduces an edge effect correction term according to the method proposed by Ripley (1977) and extended to circular and complex sampling windows by Goreaud & P?Pelissier (1999).

Theoretical values under the null hypothesis of CSR as well as local Monte Carlo confidence limits and p-values of departure from CSR (Besag & Diggle 1977) are estimated at each distance r.

### Value

A list of class `"fads"` with essentially the following components:

 `r ` a vector of regularly spaced out distances (`seq(by,upto,by)`). `g ` a data frame containing values of the pair density function g(r). `n ` a data frame containing values of the local neighbour density function n(r). `k ` a data frame containing values of Ripley's function K(r). `l ` a data frame containing values of the modified Ripley's function L(r). Each component except `r` is a data frame with the following variables: `obs ` a vector of estimated values for the observed point pattern. `theo ` a vector of theoretical values expected for a Poisson pattern. `sup ` (optional) if `nsim>0` a vector of the upper local confidence limits of a Poisson pattern at a significant level α. `inf ` (optional) if `nsim>0` a vector of the lower local confidence limits of a Poisson pattern at a significant level α. `pval ` (optional) if `nsim>0` a vector of local p-values of departure from a Poisson pattern.

### Warning

Function `kfun` ignores the marks of multivariate and marked point patterns, which are analysed as univariate patterns.

### Note

There are printing and plotting methods for `"fads"` objects.

### Author(s)

Raphael.Pelissier@ird.fr

### References

Besag J.E. 1977. Discussion on Dr Ripley's paper. Journal of the Royal Statistical Society B, 39:193-195.

Besag J.E. & Diggle P.J. 1977. Simple Monte Carlo tests spatial patterns. Applied Statistics, 26:327-333.

Goreaud F. & P?Pelissier R. 1999. On explicit formulas of edge effect correction for Ripley's K-function. Journal of Vegetation Science, 10:433-438.

Ripley B.D. 1977. Modelling spatial patterns. Journal of the Royal Statistical Society B, 39:172-192.

Stoyan D., Kendall W.S. & Mecke J. 1987. Stochastic geometry and its applications. Wiley, New-York.

`plot.fads`, `spp`, `kval`, `k12fun`, `kijfun`, `ki.fun`, `kmfun`.

### Examples

```  data(BPoirier)
BP <- BPoirier
## Not run: spatial point pattern in a rectangle sampling window of size [0,110] x [0,90]
swr <- spp(BP\$trees, win=BP\$rect)
kswr <- kfun(swr,25,1,500)
plot(kswr)

## Not run: spatial point pattern in a circle with radius 50 centred on (55,45)
swc <- spp(BP\$trees, win=c(55,45,45))
kswc <- kfun(swc, 25, 1, 500)
plot(kswc)

## Not run: spatial point pattern in a complex sampling window
swrt <- spp(BP\$trees, win=BP\$rect, tri=BP\$tri1)
kswrt <- kfun(swrt, 25, 1, 500)
plot(kswrt)
```