# nnclean

##### Nearest Neighbour Clutter Removal

Detect features in a 2D or 3D spatial point pattern using nearest neighbour clutter removal.

##### Usage

```
nnclean(X, k, ...)
## S3 method for class 'ppp':
nnclean(X, k, ...,
edge.correct = FALSE, wrap = 0.1,
convergence = 0.001, plothist = FALSE,
verbose = TRUE, maxit = 50)
## S3 method for class 'pp3':
nnclean(X, k, ...,
convergence = 0.001, plothist = FALSE,
verbose = TRUE, maxit = 50)
```

##### Arguments

- X
- A two-dimensional spatial point pattern (object of class
`"ppp"`

) or a three-dimensional point pattern (object of class`"pp3"`

). - k
- Degree of neighbour:
`k=1`

means nearest neighbour,`k=2`

means second nearest, etc. - ...
- Ignored.
- edge.correct
- Logical flag specifying whether periodic edge correction should be performed (only implemented in 2 dimensions).
- wrap
- Numeric value specifying the relative size of the margin
in which data will be replicated for the
periodic edge correction (if
`edge.correct=TRUE`

). A fraction of window width and window height. - convergence
- Tolerance threshold for testing convergence of EM algorithm.
- maxit
- Maximum number of iterations for EM algorithm.
- plothist
- Logical flag specifying whether to plot a diagnostic histogram of the nearest neighbour distances and the fitted distribution.
- verbose
- Logical flag specifying whether to print progress reports.

##### Details

Byers and Raftery (1998) developed a technique for recognising features in a spatial point pattern in the presence of random clutter.

For each point in the pattern, the distance to the $k$th nearest neighbour is computed. Then the E-M algorithm is used to fit a mixture distribution to the nearest neighbour distances. The mixture components represent the feature and the clutter. The mixture model can be used to classify each point as belong to one or other component.

The function `nnclean`

is generic, with methods for
two-dimensional point patterns (class `"ppp"`

)
and three-dimensional point patterns (class `"pp3"`

)
currently implemented.

The result is a point pattern (2D or 3D) with two additional columns of marks: [object Object],[object Object]

##### Value

- An object of the same kind as
`X`

, obtained by attaching marks to the points of`X`

.

##### References

Byers, S. and Raftery, A.E. (1998)
Nearest-neighbour clutter removal for estimating features
in spatial point processes.
*Journal of the American Statistical Association*
**93**, 577--584.

##### See Also

##### Examples

```
data(shapley)
X <- nnclean(shapley, k=17)
plot(X, chars=c(".", "+"), cols=1:2)
Y <- split(X)
plot(Y, chars="+", cex=0.5)
marks(X) <- marks(X)$prob
plot(cut(X, breaks=3), chars=c(".", "+", "+"), cols=1:3)
```

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