# Kdot.inhom

##### Inhomogeneous Multitype K Dot Function

For a multitype point pattern, estimate the inhomogeneous version of the dot \(K\) function, which counts the expected number of points of any type within a given distance of a point of type \(i\), adjusted for spatially varying intensity.

- Keywords
- spatial, nonparametric

##### Usage

```
Kdot.inhom(X, i, lambdaI=NULL, lambdadot=NULL, …, r=NULL, breaks=NULL,
correction = c("border", "isotropic", "Ripley", "translate"),
sigma=NULL, varcov=NULL, lambdaIdot=NULL,
lambdaX=NULL, update=TRUE, leaveoneout=TRUE)
```

##### Arguments

- X
The observed point pattern, from which an estimate of the inhomogeneous cross type \(K\) function \(K_{i\bullet}(r)\) will be computed. It must be a multitype point pattern (a marked point pattern whose marks are a factor). See under Details.

- i
The type (mark value) of the points in

`X`

from which distances are measured. A character string (or something that will be converted to a character string). Defaults to the first level of`marks(X)`

.- lambdaI
Optional. Values of the estimated intensity of the sub-process of points of type

`i`

. Either a pixel image (object of class`"im"`

), a numeric vector containing the intensity values at each of the type`i`

points in`X`

, a fitted point process model (object of class`"ppm"`

or`"kppm"`

or`"dppm"`

), or a`function(x,y)`

which can be evaluated to give the intensity value at any location.- lambdadot
Optional. Values of the estimated intensity of the entire point process, Either a pixel image (object of class

`"im"`

), a numeric vector containing the intensity values at each of the points in`X`

, a fitted point process model (object of class`"ppm"`

or`"kppm"`

or`"dppm"`

), or a`function(x,y)`

which can be evaluated to give the intensity value at any location.- …
Ignored.

- r
Optional. Numeric vector giving the values of the argument \(r\) at which the cross K function \(K_{ij}(r)\) should be evaluated. There is a sensible default. First-time users are strongly advised not to specify this argument. See below for important conditions on \(r\).

- breaks
This argument is for internal use only.

- correction
A character vector containing any selection of the options

`"border"`

,`"bord.modif"`

,`"isotropic"`

,`"Ripley"`

,`"translate"`

,`"translation"`

,`"none"`

or`"best"`

. It specifies the edge correction(s) to be applied. Alternatively`correction="all"`

selects all options.- sigma
Standard deviation of isotropic Gaussian smoothing kernel, used in computing leave-one-out kernel estimates of

`lambdaI`

,`lambdadot`

if they are omitted.- varcov
Variance-covariance matrix of anisotropic Gaussian kernel, used in computing leave-one-out kernel estimates of

`lambdaI`

,`lambdadot`

if they are omitted. Incompatible with`sigma`

.- lambdaIdot
Optional. A matrix containing estimates of the product of the intensities

`lambdaI`

and`lambdadot`

for each pair of points, the first point of type`i`

and the second of any type.- lambdaX
Optional. Values of the intensity for all points of

`X`

. Either a pixel image (object of class`"im"`

), a numeric vector containing the intensity values at each of the points in`X`

, a fitted point process model (object of class`"ppm"`

or`"kppm"`

or`"dppm"`

), or a`function(x,y)`

which can be evaluated to give the intensity value at any location. If present, this argument overrides both`lambdaI`

and`lambdadot`

.- update
Logical value indicating what to do when

`lambdaI`

,`lambdadot`

or`lambdaX`

is a fitted point process model (class`"ppm"`

,`"kppm"`

or`"dppm"`

). If`update=TRUE`

(the default), the model will first be refitted to the data`X`

(using`update.ppm`

or`update.kppm`

) before the fitted intensity is computed. If`update=FALSE`

, the fitted intensity of the model will be computed without re-fitting it to`X`

.- leaveoneout
Logical value (passed to

`density.ppp`

or`fitted.ppm`

) specifying whether to use a leave-one-out rule when calculating the intensity.

##### Details

This is a generalisation of the function `Kdot`

to include an adjustment for spatially inhomogeneous intensity,
in a manner similar to the function `Kinhom`

.

Briefly, given a multitype point process, consider the points without their types, and suppose this unmarked point process has intensity function \(\lambda(u)\) at spatial locations \(u\). Suppose we place a mass of \(1/\lambda(\zeta)\) at each point \(\zeta\) of the process. Then the expected total mass per unit area is 1. The inhomogeneous ``dot-type'' \(K\) function \(K_{i\bullet}^{\mbox{inhom}}(r)\) equals the expected total mass within a radius \(r\) of a point of the process of type \(i\), discounting this point itself.

If the process of type \(i\) points were independent of the points of other types, then \(K_{i\bullet}^{\mbox{inhom}}(r)\) would equal \(\pi r^2\). Deviations between the empirical \(K_{i\bullet}\) curve and the theoretical curve \(\pi r^2\) suggest dependence between the points of types \(i\) and \(j\) for \(j\neq i\).

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, and the mark vector
`X$marks`

must be a factor.

The argument `i`

will be interpreted as a
level of the factor `X$marks`

. (Warning: this means that
an integer value `i=3`

will be interpreted as the number 3,
**not** the 3rd smallest level).
If `i`

is missing, it defaults to the first
level of the marks factor, `i = levels(X$marks)[1]`

.

The argument `lambdaI`

supplies the values
of the intensity of the sub-process of points of type `i`

.
It may be either

- a pixel image
(object of class

`"im"`

) which gives the values of the type`i`

intensity at all locations in the window containing`X`

;- a numeric vector
containing the values of the type

`i`

intensity evaluated only at the data points of type`i`

. The length of this vector must equal the number of type`i`

points in`X`

.- a function
of the form

`function(x,y)`

which can be evaluated to give values of the intensity at any locations.- a fitted point process model
(object of class

`"ppm"`

,`"kppm"`

or`"dppm"`

) whose fitted*trend*can be used as the fitted intensity. (If`update=TRUE`

the model will first be refitted to the data`X`

before the trend is computed.)- omitted:
if

`lambdaI`

is omitted then it will be estimated using a leave-one-out kernel smoother.

If `lambdaI`

is omitted, then it will be estimated using
a `leave-one-out' kernel smoother, as described in Baddeley,
Moller
and Waagepetersen (2000). The estimate of `lambdaI`

for a given
point is computed by removing the point from the
point pattern, applying kernel smoothing to the remaining points using
`density.ppp`

, and evaluating the smoothed intensity
at the point in question. The smoothing kernel bandwidth is controlled
by the arguments `sigma`

and `varcov`

, which are passed to
`density.ppp`

along with any extra arguments.

Similarly the argument `lambdadot`

should contain
estimated values of the intensity of the entire point process.
It may be either a pixel image, a numeric vector of length equal
to the number of points in `X`

, a function, or omitted.

Alternatively if the argument `lambdaX`

is given, then it specifies
the intensity values for all points of `X`

, and the
arguments `lambdaI`

, `lambdadot`

will be ignored.
(The two arguments `lambdaI`

, `lambdadot`

allow the user
to specify two different methods for calculating the intensities of
the two kinds of points, while `lambdaX`

ensures that the same
method is used for both kinds of points.)

For advanced use only, the optional argument `lambdaIdot`

is a matrix containing estimated
values of the products of these two intensities for each pair of
points, the first point of type `i`

and the second of any type.

The argument `r`

is the vector of values for the
distance \(r\) at which \(K_{i\bullet}(r)\) should be evaluated.
The values of \(r\) must be increasing nonnegative numbers
and the maximum \(r\) value must exceed the radius of the
largest disc contained in the window.

The argument `correction`

chooses the edge correction
as explained e.g. in `Kest`

.

The pair correlation function can also be applied to the
result of `Kcross.inhom`

; see `pcf`

.

##### Value

An object of class `"fv"`

(see `fv.object`

).

Essentially a data frame containing numeric columns

the values of the argument \(r\) at which the function \(K_{i\bullet}(r)\) has been estimated

the theoretical value of \(K_{i\bullet}(r)\) for a marked Poisson process, namely \(\pi r^2\)

##### Warnings

The argument `i`

is interpreted as
a level of the factor `X$marks`

. It is converted to a character
string if it is not already a character string.
The value `i=1`

does **not**
refer to the first level of the factor.

##### References

Moller, J. and Waagepetersen, R. Statistical Inference and Simulation for Spatial Point Processes Chapman and Hall/CRC Boca Raton, 2003.

##### See Also

##### Examples

```
# NOT RUN {
# Lansing Woods data
woods <- lansing
woods <- woods[seq(1,npoints(woods), by=10)]
ma <- split(woods)$maple
lg <- unmark(woods)
# Estimate intensities by nonparametric smoothing
lambdaM <- density.ppp(ma, sigma=0.15, at="points")
lambdadot <- density.ppp(lg, sigma=0.15, at="points")
K <- Kdot.inhom(woods, "maple", lambdaI=lambdaM,
lambdadot=lambdadot)
# Equivalent
K <- Kdot.inhom(woods, "maple", sigma=0.15)
# Fit model
fit <- ppm(woods ~ marks * polynom(x,y,2))
K <- Kdot.inhom(woods, "maple", lambdaX=fit, update=FALSE)
# synthetic example: type A points have intensity 50,
# type B points have intensity 50 + 100 * x
lamB <- as.im(function(x,y){50 + 100 * x}, owin())
lamdot <- as.im(function(x,y) { 100 + 100 * x}, owin())
X <- superimpose(A=runifpoispp(50), B=rpoispp(lamB))
K <- Kdot.inhom(X, "B", lambdaI=lamB, lambdadot=lamdot)
# }
```

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