Computes a kernel density estimate on a linear network using the Okabe-Sugihara equal-split algorithms.
densityEqualSplit(x, sigma = NULL, ...,
at = c("pixels", "points"),
leaveoneout=TRUE,
weights = NULL,
kernel = "epanechnikov", continuous = TRUE,
epsilon = 1e-06, verbose = TRUE, debug = FALSE, savehistory = TRUE)
If at="pixels"
(the default),
a pixel image on the linear network (object of class "linim"
).
If at="points"
, a numeric vector with one entry for each point
of x
.
Point pattern on a linear network (object of class "lpp"
)
to be smoothed.
Smoothing bandwidth (standard deviation of the kernel).
A numeric value in the same units as the spatial coordinates of x
.
Alternatively sigma
may be a function which selects a
bandwidth when applied to X
,
for example, bw.scott.iso
or bw.lppl
.
There is a sensible default.
Arguments passed to as.mask
determining the
resolution of the result.
String (partially matched)
specifying whether to compute the intensity values
at a fine grid of locations on the network
(at="pixels"
, the default) or
only at the points of x
(at="points"
).
Logical value indicating whether to compute a leave-one-out
estimator. Applicable only when at="points"
.
Optional. Numeric vector of weights associated with the
points of x
. Weights may be positive, negative or zero.
Character string specifying the smoothing kernel.
See dkernel
for possible options.
Logical value indicating whether to compute the
“equal-split continuous” smoother (continuous=TRUE
, the
default) or the “equal-split discontinuous” smoother
(continuous=FALSE
).
Tolerance value. A tail of the kernel with total mass
less than epsilon
may be deleted.
Logical value indicating whether to print progress reports.
Logical value indicating whether to print debugging information.
Logical value indicating whether to save the entire history of the algorithm, for the purposes of evaluating performance.
If sigma=Inf
, the resulting density estimate is
constant over all locations,
and is equal to the average density of points per unit length.
(If the network is not connected, then this rule
is applied separately to each connected component of the network).
Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Greg McSwiggan.
Kernel smoothing is applied to the points of x
using a kernel based on path distances in the network.
The result is a pixel image on the linear network (class
"linim"
) which can be plotted.
Smoothing is performed using one of the “equal-split” rules described in Okabe and Sugihara (2012).
If continuous=TRUE
(the default), smoothing is performed
using the “equal-split continuous” rule described in
Section 9.2.3 of Okabe and Sugihara (2012).
The resulting function is continuous on the linear network.
If continuous=FALSE
, smoothing is performed
using the “equal-split discontinuous” rule described in
Section 9.2.2 of Okabe and Sugihara (2012). The
resulting function is not continuous.
Computation is performed by path-tracing as described in Okabe and Sugihara (2012).
It is advisable to choose a kernel with bounded support
such as kernel="epanechnikov"
.
With a Gaussian kernel, computation time can be long, and
increases exponentially with sigma
.
Faster algorithms are available through density.lpp
.
The argument sigma
specifies the smoothing bandwidth.
If sigma
is missing or NULL
,
the default is one-eighth of the length of the shortest side
of the bounding box of x
.
If sigma
is a function in the R language, it is assumed
to be a bandwidth selection rule, and it will be applied to x
to compute the bandwidth value.
Okabe, A. and Sugihara, K. (2012) Spatial analysis along networks. Wiley.
density.lpp
X <- runiflpp(3, simplenet)
De <- density(X, 0.2, kernel="epanechnikov", verbose=FALSE)
Ded <- density(X, 0.2, kernel="epanechnikov", continuous=FALSE, verbose=FALSE)
Run the code above in your browser using DataLab