NS {sparr} | R Documentation |
Normal scale (NS) bandwidth selector
Description
Provides the asymptotically optimal fixed bandwidths for spatial or spatiotemporal normal densities based on a simple expression.
Usage
NS(
pp,
nstar = c("npoints", "geometric"),
scaler = c("silverman", "IQR", "sd", "var")
)
NS.spattemp(
pp,
tt = NULL,
nstar = "npoints",
scaler = c("silverman", "IQR", "sd", "var")
)
Arguments
pp |
An object of class |
nstar |
Optional. Controls the value to use in place of the number of
observations n in the normal scale formula. Either a character
string, |
scaler |
Optional. Controls the value for a scalar representation of
the spatial (and temporal for |
tt |
A numeric vector of equal length to the number of points in |
Details
These functions calculate scalar smoothing bandwidths for kernel density
estimates of spatial or spatiotemporal data: the optimal values would minimise the
asymptotic mean integrated squared error assuming normally distributed data; see pp. 46-48
of Silverman (1986). The NS
function returns a single bandwidth for isotropic smoothing
of spatial (2D) data. The NS.spattemp
function returns two values – one for
the spatial margin and another for the temporal margin, based on independently applying
the normal scale rule (in 2D and 1D) to the spatial and temporal margins of the supplied data.
- Effective sample size
The formula requires a sample size, and this can be minimally tailored via
nstar
. By default, the function simply uses the number of observations inpp
:nstar = "npoints"
. Alternatively, the user can specify their own value by simply supplying a single positive numeric value tonstar
. ForNS
(not applicable toNS.spattemp
), ifpp
is appp.object
with factor-valuedmarks
, then the user has the option of usingnstar = "geometric"
, which sets the sample size used in the formula to the geometric mean of the counts of observations of each mark. This can be useful for e.g. relative risk calculations, see Davies and Hazelton (2010).- Spatial (and temporal) scale
The
scaler
argument is used to specify spatial (as well as temporal, in use ofNS.spattemp
) scale. For isotropic smoothing in the spatial margin, one may use the ‘robust’ estimate of standard deviation found by a weighted mean of the interquartile ranges of thex
- andy
-coordinates of the data respectively (scaler = "IQR"
). Two other options are the raw mean of the coordinate-wise standard deviations (scaler = "sd"
), or the square root of the mean of the two variances (scaler = "var"
). A fourth option,scaler = "silverman"
(default), sets the scaling constant to be the minimum of the"IQR"
and"sd"
options; see Silverman (1986), p. 47. In use ofNS.spattemp
the univariate version of the elected scale statistic is applied to the recorded times of the data for the temporal bandwidth. Alternatively, likenstar
, the user can specify their own value by simply supplying a single positive numeric value toscaler
forNS
, or a numeric vector of length 2 (in the order of [<spatial scale>, <temporal scale>]) forNS.spattemp
.
Value
A single numeric value of the estimated spatial bandwidth for NS
, or a named numeric vector of length 2 giving
the spatial bandwidth (as h
) and the temporal bandwidth (as lambda
) for NS.spattemp
.
Warning
The NS bandwidth is an approximation, and assumes that the target density is normal. This is considered rare in most real-world applications. Nevertheless, it remains a quick and easy ‘rule-of-thumb’ method with which one may obtain a smoothing parameter. Note that a similar expression for the adaptive kernel estimator is not possible (Davies et al., 2018).
Author(s)
T.M. Davies
References
Davies, T.M. and Hazelton, M.L. (2010), Adaptive kernel estimation of spatial relative risk, Statistics in Medicine, 29(23) 2423-2437.
Davies, T.M., Flynn, C.R. and Hazelton, M.L. (2018), On the utility of asymptotic bandwidth selectors for spatially adaptive kernel density estimation, Statistics & Probability Letters [in press].
Silverman, B.W. (1986), Density Estimation for Statistics and Data Analysis, Chapman & Hall, New York.
Wand, M.P. and Jones, C.M., 1995. Kernel Smoothing, Chapman & Hall, London.
Examples
data(pbc)
NS(pbc)
NS(pbc,nstar="geometric") # uses case-control marks to replace sample size
NS(pbc,scaler="var") # set different scalar measure of spread
data(burk)
NS.spattemp(burk$cases)
NS.spattemp(burk$cases,scaler="sd")