Smooth.ppp  R Documentation 
Performs spatial smoothing of numeric values observed at a set of irregular locations. Uses kernel smoothing and leastsquares crossvalidated bandwidth selection.
## S3 method for class 'ppp'
Smooth(X, sigma=NULL,
...,
weights = rep(1, npoints(X)),
at = "pixels", leaveoneout=TRUE,
adjust = 1, varcov = NULL,
edge = TRUE, diggle = FALSE,
kernel = "gaussian",
scalekernel = is.character(kernel),
se = FALSE,
loctype = c("random", "fixed"),
wtype = c("multiplicity", "importance"),
geometric = FALSE)
markmean(X, ...)
markvar(X, sigma=NULL, ..., weights=NULL, varcov=NULL)
X 
A marked point pattern (object of class 
sigma 
Smoothing bandwidth.
A single positive number, a numeric vector of length 2,
or a function that selects the bandwidth automatically.
See 
... 
Further arguments passed to

weights 
Optional weights attached to the observations.
A numeric vector, a 
at 
String specifying whether to compute the smoothed values
at a grid of pixel locations ( 
leaveoneout 
Logical value indicating whether to compute a leaveoneout
estimator. Applicable only when 
edge , diggle 
Arguments passed to 
adjust 
Optional. Adjustment factor for the bandwidth 
varcov 
Variancecovariance matrix. An alternative
to 
kernel 
The smoothing kernel.
A character string specifying the smoothing kernel
(current options are 
scalekernel 
Logical value.
If 
se 
Logical value specifying whether to calculate standard errors. This calculation is experimental. 
loctype 
Character string (partially matched) specifying whether the point locations are assumed to be fixed or random, in the calculation of standard error. Experimental. 
wtype 
Character string (partially matched) specifying whether the weights should be interpreted as multiplicities or as importance weights, in the calculation of standard error. Experimental. 
geometric 
Logical value indicating whether to perform geometric mean smoothing instead of arithmetic mean smoothing. See Details. 
The function 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 spatiallyvarying 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 kernel weighting, using the Gaussian kernel
by default. If the observed values are v_1,\ldots,v_n
at locations x_1,\ldots,x_n
respectively,
then the smoothed value at a location u
is
(ignoring edge corrections)
g(u) = \frac{\sum_i k(ux_i) v_i}{\sum_i k(ux_i)}
where k
is the kernel (a Gaussian kernel by default).
This is known as the
NadarayaWatson smoother (Nadaraya, 1964, 1989; Watson, 1964).
By default, the smoothing kernel bandwidth is chosen by
least squares crossvalidation (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 crossvalidation,
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(ux_i) v_i w_i}{\sum_i k(ux_i) w_i}
If geometric=TRUE
then geometric mean smoothing
is performed instead of arithmetic mean smoothing.
The mark values must be nonnegative numbers.
The logarithm of the mark values is computed; these logarithmic values are
kernelsmoothed as described above; then the exponential function
is applied to the smoothed values.
An alternative to kernel smoothing is inversedistance weighting,
which is performed by idw
.
If X
has a single column of marks:
If at="pixels"
(the default), the result is
a pixel image (object of class "im"
).
Pixel values are values of the interpolated function.
If 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
.
If X
has a data frame of marks:
If 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.
If 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
.
The return value has attributes
"sigma"
and "varcov"
which report the smoothing
bandwidth that was used.
If the chosen bandwidth sigma
is very small,
kernel smoothing is mathematically equivalent
to nearestneighbour interpolation; the result will
be computed by nnmark
. This is
unless at="points"
and leaveoneout=FALSE
,
when the original mark values are returned.
.
Nadaraya, E.A. (1964) On estimating regression. Theory of Probability and its Applications 9, 141–142.
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 inversedistance 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))
head(Smooth(finpines, sigma=2, at="points"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.