View source: R/densityAdaptiveKernel.R
densityAdaptiveKernel  R Documentation 
Computes an adaptive estimate of the intensity function of a point pattern using a variablebandwidth smoothing kernel.
densityAdaptiveKernel(X, ...)
## S3 method for class 'ppp'
densityAdaptiveKernel(X, bw, ...,
weights=NULL,
at=c("pixels", "points"),
edge=TRUE, ngroups)
X 
Point pattern (object of class 
bw 
Numeric vector of smoothing bandwidths for each point in 
... 
Arguments passed to

weights 
Optional vector of numeric weights for the points of 
at 
String specifying whether to compute the intensity values
at a grid of pixel locations ( 
edge 
Logical value indicating whether to perform edge correction. 
ngroups 
Number of groups into which the bandwidth values should be partitioned and discretised. 
This function computes a spatiallyadaptive kernel estimate of the
spatiallyvarying intensity from the point pattern X
using the partitioning technique of Davies and Baddeley (2018).
The argument bw
specifies the smoothing bandwidths to be
applied to each of the points in X
. It may be a numeric vector
of bandwidth values, or a pixel image or function yielding the
bandwidth values.
If the points of X
are x_1,\ldots,x_n
and the corresponding bandwidths are
\sigma_1,\ldots,\sigma_n
then the adaptive kernel estimate of intensity at a location u
is
\hat\lambda(u) = \sum_{i=1}^n k(u, x_i, \sigma_i)
where k(u, v, \sigma)
is the value at u
of the (possibly edgecorrected) smoothing kernel with bandwidth \sigma
induced by a data point at v
.
Exact computation of the estimate above can be timeconsuming:
it takes n
times longer than fixedbandwidth smoothing.
The partitioning method of Davies and Baddeley (2018)
accelerates this computation by partitioning the range of
bandwidths into ngroups
intervals,
correspondingly subdividing the points of the pattern X
into
ngroups
subpatterns according to bandwidth,
and applying fixedbandwidth smoothing to each subpattern.
The default value of ngroups
is the integer part of the square root of
the number of points in X
, so that the computation time is
only about \sqrt{n}
times slower than fixedbandwidth
smoothing. Any positive value of ngroups
can be specified by the user. Specifying ngroups=Inf
enforces exact
computation of the estimate without partitioning. Specifying
ngroups=1
is the same as fixedbandwidth smoothing with
bandwidth sigma=median(bw)
.
If at="pixels"
(the default), the result is a pixel image.
If at="points"
, the result is a numeric vector with one entry
for each data point in X
.
The function densityAdaptiveKernel
computes one adaptive estimate of the intensity,
determined by the smoothing bandwidth values bw
.
Typically the bandwidth values are computed by first computing
a pilot estimate of the intensity, then using bw.abram
to compute the vector of bandwidths according to Abramson's rule.
This involves specifying a global bandwidth h0
.
The default bandwidths may work well in many contexts, but for optimal
bandwidth selection, this calculation should be performed repeatedly with
different values of h0
to optimise the value of h0
.
This can be computationally demanding; we recommend
the function multiscale.density
in the sparr package
which supports much faster bandwidth selection, using the FFT
method of Davies and Baddeley (2018).
and Tilman Davies.
Davies, T.M. and Baddeley, A. (2018) Fast computation of spatially adaptive kernel estimates. Statistics and Computing, 28(4), 937956.
Hall, P. and Marron, J.S. (1988) Variable window width kernel density estimates of probability densities. Probability Theory and Related Fields, 80, 3749.
Silverman, B.W. (1986) Density Estimation for Statistics and Data Analysis. Chapman and Hall, New York.
density.ppp
,
adaptive.density
,
densityVoronoi
,
im.object
.
See the function bivariate.density
in the sparr package
for a more flexible implementation, and
multiscale.density
for an implementation that is more
efficient for bandwidth selection.
Z < densityAdaptiveKernel(redwood, h0=0.1)
plot(Z, main="Adaptive kernel estimate")
points(redwood, col="white")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.