# markcorr

##### Mark Correlation Function

Estimate the marked correlation function of a marked point pattern.

- Keywords
- spatial, nonparametric

##### Usage

```
markcorr(X, f = function(m1, m2) { m1 * m2}, r=NULL,
correction=c("isotropic", "Ripley", "translate"),
method="density", ...)
```

##### Arguments

- X
- The observed point pattern.
An object of class
`"ppp"`

or something acceptable to`as.ppp`

. - f
- Function $f$ used in the definition of the
mark correlation function. There is a sensible default
that depends on the kind of marks in
`X`

. - r
- numeric vector. The values of the argument $r$ at which the mark correlation function $\rho_f(r)$ should be evaluated. There is a sensible default.
- correction
- A character vector containing any selection of the
options
`"isotropic"`

,`"Ripley"`

or`"translate"`

. It specifies the edge correction(s) to be applied. - method
- A character vector indicating the user's choice of
density estimation technique to be used. Options are
`"density"`

,`"loess"`

,`"sm"`

and`"smrep"`

. - ...
- Arguments passed to the density estimation routine
(
`density`

,`loess`

or`sm.density`

) selected by`method`

.

##### Details

The mark correlation function $\rho_f(r)$ of a marked point process $X$ is a measure of the dependence between the marks of two points of the process a distance $r$ apart. It is informally defined as $$\rho_f(r) = \frac{E[f(M_1,M_2)]}{E[f(M,M')]}$$ where $E[ ]$ denotes expectation and $M_1,M_2$ are the marks attached to two points of the process separated by a distance $r$, while $M,M'$ are independent realisations of the marginal distribution of marks.

Here $f$ is any function
$f(m_1,m_2)$
with two arguments which are possible marks of the pattern,
and which returns a nonnegative real value.
Common choices of $f$ are:
for continuous real-valued marks,
$$f(m_1,m_2) = m_1 m_2$$
for discrete marks (multitype point patterns),
$$f(m_1,m_2) = 1(m_1 = m_2)$$
and for marks taking values in $[0,2\pi)$,
$$f(m_1,m_2) = \sin(m_1 - m_2)$$.
Note that $\rho_f(r)$ is not a ``correlation''
in the usual statistical sense. It can take any
nonnegative real value. The value 1 suggests ``lack of correlation'':
if the marks attached to the points of `X`

are independent
and identically distributed, then
$\rho_f(r) \equiv 1$.
The interpretation of values larger or smaller than 1 depends
on the choice of function $f$.

The argument `X`

must be a point pattern (object of class
`"ppp"`

) or any data that are acceptable to `as.ppp`

.
It must be a marked point pattern.

The argument `f`

determines the function to be applied to
pairs of marks. It has a sensible default, which depends on the
kind of marks in `X`

. If the marks
are numeric values, then `f <- function(m1, m2) { m1 * m2}`

computes the product of two marks.
If the marks are a factor (i.e. if `X`

is a multitype point
pattern) then `f <- function(m1, m2) { m1 == m2}`

yields
the value 1 when the two marks are equal, and 0 when they are unequal.
These are the conventional definitions for numerical
marks and multitype points respectively.

Alternatively the argument `f`

may be specified by the user.
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, and `NA`

values are not permitted.

The argument `r`

is the vector of values for the
distance $r$ at which $\rho_f(r)$ is estimated.

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 in the same manner as in `Kest`

.
The edge corrections implemented here are
[object Object],[object Object]
Note that the estimator assumes the process is stationary (spatially
homogeneous).

The numerator and denominator of the mark correlation function (in the expression above) are estimated using density estimation techniques. The user can choose between [object Object],[object Object],[object Object],[object Object]

##### Value

- An object of class
`"fv"`

(see`fv.object`

). Essentially a data frame containing numeric columns r the values of the argument $r$ at which the mark correlation function $\rho_f(r)$ has been estimated theo the theoretical value of $\rho_f(r)$ when the marks attached to different points are independent, namely 1 - together with a column or columns named
`"iso"`

and/or`"trans"`

, according to the selected edge corrections. These columns contain estimates of the function $\rho_f(r)$ obtained by the edge corrections named.

##### References

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

##### See Also

##### Examples

```
# CONTINUOUS-VALUED MARKS:
# (1) Longleaf Pine data
# marks represent tree diameter
data(longleaf)
# Subset of this large pattern
swcorner <- owin(c(0,100),c(0,100))
sub <- longleaf[ , swcorner]
# mark correlation function
mc <- markcorr(sub)
plot(mc)
# (2) simulated data with independent marks
X <- rpoispp(100)
X <- X %mark% runif(X$n)
Xc <- markcorr(X)
plot(Xc)
# MULTITYPE DATA:
# Hughes' amacrine data
# Cells marked as 'on'/'off'
data(amacrine)
# (3) Kernel density estimate with Epanecnikov kernel
# (as proposed by Stoyan & Stoyan)
M <- markcorr(amacrine, function(m1,m2) {m1==m2},
correction="translate", method="density",
kernel="epanechnikov")
plot(M)
# Note: kernel="epanechnikov" comes from help(density)
# (4) Same again with explicit control over bandwidth
M <- markcorr(amacrine,
correction="translate", method="density",
kernel="epanechnikov", bw=0.02)
# see help(density) for correct interpretation of 'bw'
<testonly>data(betacells)
betacells <- betacells[seq(1,betacells$n,by=3)]
niets <- markcorr(betacells, function(m1,m2){m1 == m2}, method="loess")
niets <- markcorr(X, correction="isotropic", method="smrep", hmult=2)</testonly>
```

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