"Smooth"(X, sigma=NULL, ..., weights = rep(1, npoints(X)), at="pixels", edge=TRUE, diggle=FALSE)
markmean(X, ...)
markvar(X, sigma=NULL, ..., weights=NULL, varcov=NULL)
"ppp"
).density.ppp
.
bw.smoothppp
and density.ppp
to control the kernel smoothing and
the pixel resolution of the result.
expression
or a pixel image.
See density.ppp
.
at="pixels"
) or
only at the points of X
(at="points"
).
density.ppp
to
determine the edge correction.
sigma
. See density.ppp
.
X
has a single column of marks:
at="pixels"
(the default), the result is
a pixel image (object of class "im"
).
Pixel values are values of the interpolated function.
at="points"
, the result is a numeric vector
of length equal to the number of points in X
.
Entries are values of the interpolated function at the points of X
.
X
has a data frame of marks:
at="pixels"
(the default), the result is a named list of
pixel images (object of class "im"
). There is one
image for each column of marks. This list also belongs to
the class "solist"
, for which there is a plot method.
at="points"
, the result is a data frame
with one row for each point of X
,
and one column for each column of marks.
Entries are values of the interpolated function at the points of X
.
"sigma"
and "varcov"
which report the smoothing
bandwidth that was used.
sigma
is very small,
kernel smoothing is mathematically equivalent
to nearest-neighbour interpolation; the result will
be computed by nnmark
. This is
unless at="points"
and leaveoneout=FALSE
,
when the original mark values are returned.Smooth.ppp
performs spatial smoothing of numeric values
observed at a set of irregular locations. The functions
markmean
and markvar
are wrappers for Smooth.ppp
which compute the spatially-varying mean and variance of the marks of
a point pattern. Smooth.ppp
is a method for the generic function
Smooth
for the class "ppp"
of point patterns.
Thus you can type simply Smooth(X)
.
Smoothing is performed by Gaussian kernel weighting. If the
observed values are $v[1],...,v[n]$
at locations $x[1],...,x[n]$ respectively,
then the smoothed value at a location $u$ is
(ignoring edge corrections)
$$
g(u) = \frac{\sum_i k(u-x_i) v_i}{\sum_i k(u-x_i)}
$$
where $k$ is a Gaussian kernel. This is known as the
Nadaraya-Watson smoother (Nadaraya, 1964, 1989; Watson, 1964).
By default, the smoothing kernel bandwidth is chosen by
least squares cross-validation (see below).
The argument X
must be a marked point pattern (object
of class "ppp"
, see ppp.object
).
The points of the pattern are taken to be the
observation locations $x[i]$, and the marks of the pattern
are taken to be the numeric values $v[i]$ observed at these
locations.
The marks are allowed to be a data frame (in
Smooth.ppp
and markmean
). Then the smoothing procedure is applied to each
column of marks.
The numerator and denominator are computed by density.ppp
.
The arguments ...
control the smoothing kernel parameters
and determine whether edge correction is applied.
The smoothing kernel bandwidth can be specified by either of the arguments
sigma
or varcov
which are passed to density.ppp
.
If neither of these arguments is present, then by default the
bandwidth is selected by least squares cross-validation,
using bw.smoothppp
.
The optional argument weights
allows numerical weights to
be applied to the data. If a weight $w[i]$
is associated with location $x[i]$, then the smoothed
function is
(ignoring edge corrections)
$$
g(u) = \frac{\sum_i k(u-x_i) v_i w_i}{\sum_i k(u-x_i) w_i}
$$
An alternative to kernel smoothing is inverse-distance weighting,
which is performed by idw
.
Nadaraya, E.A. (1989) Nonparametric estimation of probability densities and regression curves. Kluwer, Dordrecht.
Watson, G.S. (1964) Smooth regression analysis. Sankhya A 26, 359--372.
Smooth
,
density.ppp
,
bw.smoothppp
,
nnmark
,
ppp.object
,
im.object
. See idw
for inverse-distance weighted smoothing.
To perform interpolation, see also the akima
package.
# Longleaf data - tree locations, marked by tree diameter
# Local smoothing of tree diameter (automatic bandwidth selection)
Z <- Smooth(longleaf)
# Kernel bandwidth sigma=5
plot(Smooth(longleaf, 5))
# mark variance
plot(markvar(longleaf, sigma=5))
# data frame of marks: trees marked by diameter and height
plot(Smooth(finpines, sigma=2))
Run the code above in your browser using DataLab