The interaction between two arbitrary points is measured by
*second-order properties*, which reflect the tendency of the
events to appear clustered (points tend to be close together),
independently (the Poisson process) or regularly spaced (points tend to
avoid each other).

We start this section by loading the required data sets and packages.

```
library(spatstat)
library(rasterVis)
load(url("https://userpage.fu-berlin.de/soga/data/r-data/ppp_data_berlin.RData"))
```

```
par(mar = c(0, 0, 2, 2),
mfrow = c(1, 3),
cex.main = 2)
plot(ppp_random, main = "independant")
plot(ppp_regular, main = "regular")
plot(ppp_locations, main = "clustered")
```

A simple diagnostic option or dependence between points is the
*Fry plot*. It is a scatterplot of the vector differences \(x_j - x_i\) between all pairs of distinct
points in the pattern. In `spatstat`

, the Fry plot is
computed by the command `fryplot()`

.

```
par(mar = c(0, 0, 3, 2),
mfrow = c(1, 3),
cex.main = 2)
fryplot(ppp_random, main = "independant", pch = 16, cex = 0.2)
fryplot(ppp_regular, main = "regular", pch = 16, cex = 0.2)
fryplot(ppp_locations, main = "clustered", pch = 16, cex = 0.2)
```

Classical techniques for investigating inter-point interaction are
*distance methods*, based on measuring the distances between
points (Baddeley 2010):

**pairwise distances**\(s_{ij} = \Vert x_i - x_j \Vert\) between all distinct pairs of points \(x_i\) and \(x_j\) \((i \ne j)\) in the pattern**nearest neighbor distances**\(t_i = \min_{j \ne i}s_{ij}\), the distance from each point \(x_i\) to its nearest neighbor**empty space distances**\(d(u) = \min \Vert u-x_i \Vert\), the distance from a fixed reference location \(u\) in the window to the nearest data point

These methods are available in the `spatstat`

package
using the functions `pairdist()`

, `nndist()`

and
`distmap()`

respectively.

```
par(mar = c(2, 2, 2, 2), mfrow = c(1, 3), oma = c(0, 0, 2, 0))
hist(pairdist(ppp_locations),
freq = FALSE,
breaks = nrow(pairdist(ppp_locations)),
main = "independant",
xlim = c(0, 40000)
)
hist(pairdist(ppp_regular),
freq = FALSE,
breaks = nrow(pairdist(ppp_regular)),
main = "regular"
)
hist(pairdist(ppp_random),
freq = FALSE, breaks = nrow(pairdist(ppp_random)), main = "clustered"
)
mtext("Pairwise Distances Histogram", outer = TRUE, cex = 1.5)
```

`levelplot(pairdist(ppp_random), main = "Pairwise Distances: independant", par.settings=BTCTheme())`

`levelplot(pairdist(ppp_regular), main = "Pairwise Distances: regular", par.settings=BTCTheme())`

`levelplot(pairdist(ppp_locations), main = "Pairwise Distances: clustered", par.settings=BTCTheme())`