nncorr(X,
f = function(m1, m2) { m1 * m2 },
...,
use = "all.obs", method = c("pearson", "kendall", "spearman"))
"ppp"
.f
.cor
. Three different values are computed: the unnormalised, normalised,
and classical correlations.
The unnormalised nearest neighbour correlation (Stoyan and Stoyan,
1994, section 14.7) is defined as
Note that $\bar n_f$ is not a ``correlation'' in the usual statistical sense. It can take values greater than 1.
We can define a normalised nearest neighbour correlation
by
X
are independent
and identically distributed, then
$\bar m_f = 1$.
The interpretation of values larger or smaller than 1 depends
on the choice of function $f$.
Finally if the marks of X
are real numbers, we can also compute the
classical correlation, that is, the correlation coefficient
of the two random variables $M$ and $M^\ast$.
The classical correlation has a value between $-1$ and $1$.
Values close to $-1$ or $1$ indicate strong dependence between
the marks.
This function computes the unnormalised and normalised nearest neighbour correlations, and the classical correlation if appropriate.
The argument X
must be a point pattern (object of class
"ppp"
) and must be a marked point pattern.
The argument f
must be a function, accepting two arguments m1
and m2
which are vectors of equal length containing mark
values (of the same type as the marks of X
).
It must return a vector of numeric
values of the same length as m1
and m2
.
The values must be non-negative.
The arguments use
and method
control
the calculation of the classical correlation using cor
,
as explained in the help file for cor
.
Other arguments may be passed to f
through the ...
argument.
This algorithm assumes that X
can be treated
as a realisation of a stationary (spatially homogeneous)
random spatial point process in the plane, observed through
a bounded window.
The window (which is specified in X
as X$window
)
may have arbitrary shape.
Biases due to edge effects are
treated using the
data(finpines)
nncorr(finpines)
# heights of neighbouring trees are slightly negatively correlated
data(amacrine)
nncorr(amacrine, function(m1, m2) { m1 == m2})
# neighbouring cells are usually of different type
Run the code above in your browser using DataLab