compileK(D, r, weights = NULL, denom = 1, check = TRUE, ratio = FALSE, fname = "K")
compilepcf(D, r, weights = NULL, denom = 1, check = TRUE, endcorrect = TRUE, ..., fname = "g")
D
.
If absent, the weights are taken to equal 1.
r
. See Details.
D
is a
valid matrix of pairwise distances.
density.default
controlling the kernel smoothing.
r=0
.
"fv"
representing the estimated function.
These functions are useful for code development and for teaching,
because they perform a common task, and do the housekeeping required to
make an object of class "fv"
that represents the estimated
function. However, they are not very efficient.
compileK
calculates the weighted estimate
of the $K$ function,
$$
\hat K(r) = (1/v(r)) \sum_i \sum_j 1\{ d_{ij} \le r\} w_{ij}
$$
and compilepcf
calculates the weighted estimate of the
pair correlation function,
$$
\hat g(r) = (1/v(r)) \sum_i \sum_j \kappa( d_{ij} - r ) w_{ij}
$$
where $d[i,j]$ is the distance between spatial points
$i$ and $j$, with corresponding weight $w[i,j]$,
and $v(r)$ is a specified denominator. Here $\kappa$
is a fixed-bandwidth smoothing kernel.
For a point pattern in two dimensions, the usual denominator $v(r)$ is constant for the $K$ function, and proportional to $r$ for the pair correlation function. See the Examples.
The result is an object of class "fv"
representing the
estimated function. This object has only one column of function
values. Additional columns (such as a column giving the theoretical
value) must be added by the user, with the aid of
bind.fv
.
Kest
,
pcf
for definitions of the $K$ function
and pair correlation function.
bind.fv
to add more columns.
X <- japanesepines
D <- pairdist(X)
Wt <- edge.Ripley(X, D)
lambda <- intensity(X)
a <- (npoints(X)-1) * lambda
r <- seq(0, 0.25, by=0.01)
K <- compileK(D=D, r=r, weights=Wt, denom=a)
g <- compilepcf(D=D, r=r, weights=Wt, denom= a * 2 * pi * r)
Run the code above in your browser using DataLab