Kcross.inhom(X, i=1, j=2, lambdaI, lambdaJ, ..., r=NULL, breaks=NULL,
correction = c("border", "isotropic", "Ripley", "translate") ,
lambdaIJ=NULL)
X
from which distances are measured.X
to which distances are measured.i
.
Either a pixel image (object of class "im"
),
or a numeric vector containing the intensity values
at each of the type i
poij
.
Either a pixel image (object of class "im"
),
or a numeric vector containing the intensity values
at each of the type j
poir
.
Not normally invoked by the user. See the Details section."border"
, "bord.modif"
,
"isotropic"
, "Ripley"
or "translate"
.
It specifies the edge correction(s) to be applied.lambdaI
and lambdaJ
for each pair of points of types i
and j
respectively."fv"
(see fv.object
).Essentially a data frame containing numeric columns
"border"
, "bord.modif"
,
"iso"
and/or "trans"
,
according to the selected edge corrections. These columns contain
estimates of the function $K_{ij}(r)$
obtained by the edge corrections named.i
and j
are interpreted as
levels of the factor X$marks
. Beware of the usual
trap with factors: numerical values are not
interpreted in the same way as character values.Kcross
to include an adjustment for spatially inhomogeneous intensity,
in a manner similar to the function Kinhom
.The inhomogeneous cross-type $K$ function is described by Moller and Waagepetersen (2003, pages 48-49 and 51-53). Briefly, given a multitype point process, suppose the sub-process of points of type $j$ has intensity function $\lambda_j(u)$ at spatial locations $u$. Suppose we place a mass of $1/\lambda_j(\zeta)$ at each point $\zeta$ of type $j$. Then the expected total mass per unit area is 1. The inhomogeneous ``cross-type'' $K$ function $K_{ij}^{\mbox{inhom}}(r)$ equals the expected total mass within a radius $r$ of a point of the process of type $i$. If the process of type $i$ points were independent of the process of type $j$ points, then $K_{ij}^{\mbox{inhom}}(r)$ would equal $\pi r^2$. Deviations between the empirical $K_{ij}$ curve and the theoretical curve $\pi r^2$ suggest dependence between the points of types $i$ and $j$.
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 arguments i
and j
will be interpreted as
levels of the factor X$marks
. (Warning: this means that
an integer value i=3
will be interpreted as the 3rd smallest level,
not the number 3).
The argument lambdaI
supplies the values
of the intensity of the sub-process of points of type i
.
It may be either
[object Object],[object Object]
Similarly lambdaJ
should contain
estimated values of the intensity of the sub-process of points of
type j
. It may be either a pixel image or a numeric vector.
The optional argument lambdaIJ
is for advanced use only.
It is a matrix containing estimated
values of the products of these two intensities for each pair of
data points of types i
and j
respectively.
The argument r
is the vector of values for the
distance $r$ at which $K_{ij}(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
.
Kcross
,
Kinhom
,
pcf
# Lansing Woods data
data(lansing)
lansing <- lansing[seq(1,lansing$n, by=10)]
ma <- split(lansing)$maple
wh <- split(lansing)$whiteoak
# method (1): estimate intensities by nonparametric smoothing
lambdaM <- density.ppp(ma, sigma=0.15)
lambdaW <- density.ppp(wh, sigma=0.15)
K <- Kcross.inhom(lansing, "whiteoak", "maple", lambdaW[wh], lambdaM[ma])
K <- Kcross.inhom(lansing, "whiteoak", "maple", lambdaW, lambdaM)
# method (2): fit parametric intensity model
fit <- ppm(lansing, ~marks * polynom(x,y,2))
# evaluate fitted intensities at data points
# (these are the intensities of the sub-processes of each type)
inten <- fitted(fit, dataonly=TRUE)
# split according to types of points
lambda <- split(inten, lansing$marks)
K <- Kcross.inhom(lansing, "whiteoak", "maple",
lambda$whiteoak, lambda$maple)
# synthetic example: type A points have intensity 50,
# type B points have intensity 100 * x
lamB <- as.im(function(x,y){50 + 100 * x}, owin())
X <- superimpose(A=runifpoispp(50), B=rpoispp(lamB))
XA <- split(X)$A
XB <- split(X)$B
K <- Kcross.inhom(X, "A", "B",
lambdaI=rep(50, XA$n), lambdaJ=lamB[XB])
K <- Kcross.inhom(X, "A", "B",
lambdaI=as.im(50, X$window), lambdaJ=lamB)
Run the code above in your browser using DataLab