Estimates the reduced second moment measure \(\kappa\) from a point pattern in a window of arbitrary shape.

`Kmeasure(X, sigma, edge=TRUE, …, varcov=NULL)`

X

The observed point pattern,
from which an estimate of \(\kappa\) will be computed.
An object of class `"ppp"`

, or data
in any format acceptable to `as.ppp()`

.

sigma

Standard deviation \(\sigma\) of the Gaussian
smoothing kernel. Incompatible with `varcov`

.

edge

Logical value indicating whether an edge correction should be applied.

…

Arguments passed to `as.mask`

controlling
the pixel resolution.

varcov

Variance-covariance matrix of the Gaussian smoothing kernel.
Incompatible with `sigma`

.

A real-valued pixel image (an object of class `"im"`

,
see `im.object`

) whose pixel values are estimates
of the density of the reduced second moment measure
at each location.

Some writers use the term *reduced second moment measure*
when they mean the \(K\)-function. This has caused
confusion.

As originally defined, the
reduced second moment measure is a measure, obtained by modifying
the second moment measure, while the \(K\)-function is a function
obtained by evaluating this measure for discs of increasing radius.
In spatstat, the \(K\)-function is computed by
`Kest`

and the reduced second moment measure is computed
by `Kmeasure`

.

Given a point pattern dataset, this command computes an estimate of the reduced second moment measure \(\kappa\) of the point process. The result is a pixel image whose pixel values are estimates of the density of the reduced second moment measure.

The reduced second moment measure \(\kappa\) can be regarded as a generalisation of the more familiar \(K\)-function. An estimate of \(\kappa\) derived from a spatial point pattern dataset can be useful in exploratory data analysis. Its advantage over the \(K\)-function is that it is also sensitive to anisotropy and directional effects.

In a nutshell, the command `Kmeasure`

computes a smoothed version
of the *Fry plot*.
As explained under `fryplot`

, the Fry plot is a scatterplot of the
vectors joining all pairs of points in the pattern.
The reduced second moment measure is (essentially) defined as
the average of the Fry plot over different realisations of the point
process. The command `Kmeasure`

effectively smooths the Fry plot
of a dataset to obtain an estimate of the reduced second moment measure.

In formal terms, the reduced second moment measure \(\kappa\) of a stationary point process \(X\) is a measure defined on the two-dimensional plane such that, for a `typical' point \(x\) of the process, the expected number of other points \(y\) of the process such that the vector \(y - x\) lies in a region \(A\), equals \(\lambda \kappa(A)\). Here \(\lambda\) is the intensity of the process, i.e. the expected number of points of \(X\) per unit area.

The \(K\)-function is a special case. The function value \(K(t)\) is the value of the reduced second moment measure for the disc of radius \(t\) centred at the origin; that is, \(K(t) = \kappa(b(0,t))\).

The command `Kmeasure`

computes an estimate of \(\kappa\)
from a point pattern dataset `X`

,
which is assumed to be a realisation of a stationary point process,
observed inside a known, bounded window. Marks are ignored.

The algorithm approximates the point pattern and its window by binary pixel
images, introduces a Gaussian smoothing kernel
and uses the Fast Fourier Transform `fft`

to form a density estimate of \(\kappa\). The calculation
corresponds to the edge correction known as the ``translation
correction''.

The Gaussian smoothing kernel may be specified by either of the
arguments `sigma`

or `varcov`

. If `sigma`

is a single
number, this specifies an isotropic Gaussian kernel
with standard deviation `sigma`

on each coordinate axis.
If `sigma`

is a vector of two numbers, this specifies a Gaussian
kernel with standard deviation `sigma[1]`

on the \(x\) axis,
standard deviation `sigma[2]`

on the \(y\) axis, and zero
correlation between the \(x\) and \(y\) axes. If `varcov`

is
given, this specifies the variance-covariance matrix of the
Gaussian kernel. There do not seem to be any well-established rules
for selecting the smoothing kernel in this context.

The density estimate of \(\kappa\)
is returned in the form of a real-valued pixel image.
Pixel values are estimates of the normalised
second moment density at the centre of the pixel.
(The uniform Poisson process would have values identically equal to
\(1\).)
The image `x`

and `y`

coordinates are on the same scale as vector displacements in the
original point pattern window. The point `x=0, y=0`

corresponds
to the `typical point'.
A peak in the image near `(0,0)`

suggests clustering;
a dip in the image near `(0,0)`

suggests inhibition;
peaks or dips at other positions suggest possible periodicity.

If desired, the value of \(\kappa(A)\) for a region
\(A\) can be estimated by computing the integral of the pixel image
over the domain \(A\), i.e.\ summing the pixel values and
multiplying by pixel area, using `integral.im`

.
One possible application is to compute anisotropic counterparts of the
\(K\)-function (in which the disc of radius \(t\) is replaced
by another shape). See Examples.

Stoyan, D, Kendall, W.S. and Mecke, J. (1995)
*Stochastic geometry and its applications*.
2nd edition. Springer Verlag.

Stoyan, D. and Stoyan, H. (1994) Fractals, random shapes and point fields: methods of geometrical statistics. John Wiley and Sons.

# NOT RUN { plot(Kmeasure(cells, 0.05)) # shows pronounced dip around origin consistent with strong inhibition plot(Kmeasure(redwood, 0.03), col=grey(seq(1,0,length=32))) # shows peaks at several places, reflecting clustering and ?periodicity M <- Kmeasure(cells, 0.05) # evaluate measure on a sector W <- Window(M) ang <- as.im(atan2, W) rad <- as.im(function(x,y){sqrt(x^2+y^2)}, W) sector <- solutionset(ang > 0 & ang < 1 & rad < 0.6) integral.im(M[sector, drop=FALSE]) # }