bw.relrisklpp: Cross Validated Bandwidth Selection for Relative Risk...

bw.relrisklppR Documentation

Cross Validated Bandwidth Selection for Relative Risk Estimation on a Network


Uses cross-validation to select a smoothing bandwidth for the estimation of relative risk on a linear network.


  bw.relrisklpp(X, ...,
    method = c("likelihood", "leastsquares", "KelsallDiggle", "McSwiggan"),
    distance=c("path", "euclidean"),
    hmin = NULL, hmax = NULL, nh = NULL,
    fast = TRUE, fastmethod = "onestep",
    floored = TRUE, reference = c("thumb", "uniform", "sigma"),
    allow.infinite = TRUE, epsilon = 1e-20, fudge = 0,
    verbose = FALSE, warn = TRUE)



A multitype point pattern on a linear network (object of class "lpp" which has factor-valued marks).


Arguments passed to density.lpp to control the resolution of the algorithm.


Character string (partially matched) determining the cross-validation method. See Details.


Character string (partially matched) specifying the type of smoothing kernel. See density.lpp.


Optional. Numeric values. Range of trial values of smoothing bandwith sigma to consider. There is a sensible default.


Number of trial values of smoothing bandwidth sigma to consider.


Logical value specifying whether the leave-one-out density estimates should be computed using a fast approximation (fast=TRUE, the default) or exactly (fast=FALSE).

fastmethod, floored

Developer use only.


Character string (partially matched) specifying the bandwidth for calculating the reference intensities used in the McSwiggan method (modified Kelsall-Diggle method). reference="sigma" means the maximum bandwidth considered, which is given by the argument sigma. reference="thumb" means the bandwidths selected by Scott's rule of thumb bw.scott.iso. reference="uniform" means infinite bandwidth corresponding to uniform intensity.


Logical value indicating whether an infinite bandwidth (corresponding to a constant relative risk) should be permitted as a possible choice of bandwidth.


A small constant value added to the reference density in some of the cross-validation calculations, to improve performance.


Fudge factor to prevent very small density estimates in the leave-one-out calculation. If fudge > 0, then the lowest permitted value for a leave-one-out estimate of intensity is fudge/L, where L is the total length of the network.


Logical value indicating whether to print progress reports,


Logical. If TRUE, issue a warning if the minimum of the cross-validation criterion occurs at one of the ends of the search interval.


This function computes an optimal value of smoothing bandwidth for the nonparametric estimation of relative risk on a linear network using relrisk.lpp. The optimal value is found by optimising a cross-validation criterion.

The cross-validation criterion is selected by the argument method:

method="likelihood" likelihood cross-validation
method="leastsquares" least squares cross-validation
method="KelsallDiggle" Kelsall and Diggle (1995) density ratio cross-validation
method="McSwiggan" McSwiggan et al (2019) modified density ratio cross-validation

See McSwiggan et al (2019) for details.

The result 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 linear network version of Scott's rule bw.scott.iso.

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.

The cross-validation procedure is based on kernel estimates of intensity, which are computed by density.lpp. Any arguments ... are passed to density.lpp to control the kernel estimation procedure. This includes the argument distance which specifies the type of kernel. The default is distance="path"; the fastest option is distance="euclidean".


A numerical value giving the selected bandwidth. The result also belongs to the class "bw.optim" which can be plotted.


Greg McSwiggan and \adrian.


Kelsall, J.E. and Diggle, P.J. (1995) Kernel estimation of relative risk. Bernoulli 1, 3–16.

McSwiggan, G., Baddeley, A. and Nair, G. (2019) Estimation of relative risk for events on a linear network. Statistics and Computing 30 (2) 469–484.

See Also



   X <- superimpose(A=runiflpp(20, simplenet),
                    B=runifpointOnLines(20, as.psp(simplenet)[1]))
   plot(bw.relrisklpp(X, hmin=0.1, hmax=0.25, method="McSwiggan"))
   plot(bw.relrisklpp(X, hmin=0.1, hmax=0.3, nh=8, distance="euclidean"))

spatstat.linnet documentation built on March 18, 2022, 6:40 p.m.