nncorr
),
the nearest-neighbour mark index (nnmean
),
and the nearest-neighbour variogram index (nnvario
).
nncorr(X, f = function(m1, m2) { m1 * m2 }, k = 1, ..., use = "all.obs", method = c("pearson", "kendall", "spearman"), denominator=NULL) nnmean(X, k=1) nnvario(X, k=1)
"ppp"
.
X
.
k
-th nearest neighbour of each point will be used.
f
.
cor
.
The command nncorr
computes the nearest neighbour correlation index
based on any test function f
provided by the user.
The default behaviour of nncorr
is to compute the
nearest neighbour mark product index.
The commands nnmean
and nnvario
are
convenient abbreviations for other special choices of f
.
In the default case, nncorr(X)
computes three different
versions of the nearest-neighbour correlation index:
the unnormalised, normalised, and classical correlations.
In the default case where f
is not given,
nncorr(X)
computes
X
are real numbers,
the unnormalised and normalised
versions of the nearest-neighbour product index
$E[M * M*]$,
and the classical correlation
between $M$ and $M*$.
X
are factor valued,
the unnormalised and normalised
versions of the nearest-neighbour equality index
$P[M = M*]$.
The wrapper functions nnmean
and nnvario
compute the correlation indices for two special choices of the
function $f(m1,m2)$.
nnmean
computes the correlation indices for
$f(m1,m2) = m1$. The unnormalised index
is simply the mean value of the mark of the neighbour of a typical point,
$E[M*]$, while the normalised index is
$E[M*]/E[M]$, the ratio of the mean mark of the
neighbour of a typical point to the mean mark of a typical point.
nnvario
computes the correlation indices for
$f(m1,m2) = (1/2) * (m1-m2)^2$.
The argument X
must be a point pattern (object of class
"ppp"
) and must be a marked point pattern.
(The marks may be a data frame, containing several columns of mark variables;
each column is treated separately.)
If the argument f
is given, it
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 Window(X)
)
may have arbitrary shape.
Biases due to edge effects are
treated using the border method edge correction.
data(finpines)
nncorr(finpines)
# heights of neighbouring trees are slightly negatively correlated
data(amacrine)
nncorr(amacrine)
# neighbouring cells are usually of different type
Run the code above in your browser using DataLab