# nndensity.ppp

##### Estimate Intensity of Point Pattern Using Nearest Neighbour Distances

Estimates the intensity of a point pattern
using the distance from each spatial location
to the `k`

th nearest data point.

##### Usage

`nndensity(x, ...)`# S3 method for ppp
nndensity(x, k, ..., verbose = TRUE)

##### Arguments

- x
A point pattern (object of class

`"ppp"`

) or some other spatial object.- k
Integer. The distance to the

`k`

th nearest data point will be computed. There is a sensible default.- …
Arguments passed to

`nnmap`

and`as.mask`

controlling the pixel resolution.- verbose
Logical. If

`TRUE`

, print the value of`k`

when it is automatically selected. If`FALSE`

, remain silent.

##### Details

This function computes a quick estimate of the intensity of the point
process that generated the point pattern `x`

.

For each spatial location \(s\), let \(d(s)\) be the distance from \(s\)
to the \(k\)-th nearest point in the dataset `x`

.
If the data came from a homogeneous
Poisson process with intensity \(\lambda\),
then \(\pi d(s)^2\) would follow a
negative exponential distribution with mean
\(1/\lambda\), and the maximum likelihood estimate of
\(\lambda\) would be \(1/(\pi d(s)^2)\).
This is the estimate computed by `nndensity`

,
apart from an edge effect correction.

This estimator of intensity is relatively fast to compute, and is spatially adaptive (so that it can handle wide variation in the intensity function). However, it implicitly assumes the points are independent, so it does not perform well if the pattern is strongly clustered or strongly inhibited.

The value of `k`

should be greater than 1 in order to avoid
infinite peaks in the intensity estimate around each data point.
The default value of `k`

is the square root of the number of
points in `x`

, which seems to work well in many cases.

The window of `x`

is digitised using `as.mask`

and the values \(d(s)\) are computed using `nnmap`

.
To control the pixel resolution, see `as.mask`

.

##### Value

A pixel image (object of class `"im"`

) giving the
estimated intensity of the point process at each spatial location.
Pixel values are intensities (number of points per unit area).

##### References

NEED REFERENCES. TRY CRESSIE

##### See Also

`density.ppp`

,
`intensity`

for alternative estimates of point process intensity.

##### Examples

```
# NOT RUN {
plot(nndensity(swedishpines))
# }
```

*Documentation reproduced from package spatstat, version 1.49-0, License: GPL (>= 2)*