Learn R Programming

spatstat.explore (version 3.5-3)

bw.smoothppp: Cross Validated Bandwidth Selection for Spatial Smoothing

Description

Uses least-squares cross-validation to select a smoothing bandwidth for spatial smoothing of marks.

Usage

bw.smoothppp(X, ..., nh = spatstat.options("n.bandwidth"),
                hmin=NULL, hmax=NULL, warn=TRUE, kernel="gaussian",
                varcov1=NULL, train=NULL, test=NULL)

Arguments

Value

A single numerical value giving the selected bandwidth. The result also belongs to the class "bw.optim"

(see bw.optim.object) which can be plotted to show the bandwidth selection criterion as a function of sigma.

Details

This function selects an appropriate bandwidth for the nonparametric smoothing of mark values using Smooth.ppp.

The argument X must be a marked point pattern with a vector or data frame of marks. All mark values must be numeric.

The bandwidth is selected by least-squares cross-validation. Let \(y_i\) be the mark value at the \(i\)th data point. For a particular choice of smoothing bandwidth, let \(\hat y_i\) be the smoothed value at the \(i\)th data point. Then the bandwidth is chosen to minimise the squared error of the smoothed values \(\sum_i (y_i - \hat y_i)^2\).

If the argument train is given, then spatial smoothing is calculated using only the data from the subset X[train]. If the argument test is given, then smoothed values are calculated only at the locations in the subset X[test], and squared errors are summed over the locations in X[test].

(If test is given, then this sum of squared errors is computed only over the specified subset of locations.)

The result of bw.smoothppp is a numerical value giving the selected bandwidth sigma. The result also belongs to the class "bw.optim" allowing it to be printed and plotted. The plot shows the cross-validation criterion as a function of bandwidth.

The range of values for the smoothing bandwidth sigma is set by the arguments hmin, hmax. There is a sensible default, based on the nearest neighbour distances.

If the optimal bandwidth is achieved at an endpoint of the interval [hmin, hmax], the algorithm will issue a warning (unless warn=FALSE). If this occurs, then it is probably advisable to expand the interval by changing the arguments hmin, hmax.

Computation time depends on the number nh of trial values considered, and also on the range [hmin, hmax] of values considered, because larger values of sigma require calculations involving more pairs of data points.

See Also

Smooth.ppp, bw.optim.object

Examples

Run this code
  op <- spatstat.options(n.bandwidth=8)
  b <- bw.smoothppp(longleaf)
  b
  plot(b)
  spatstat.options(op)

Run the code above in your browser using DataLab