bwd.nrd: Silverman's rule optimal for the estimation of a kernel...

Description Usage Arguments Details Value Note Note Author(s) References Examples

Description

Computes the optimal bandwidth with the Silverman's rule of thumb, to be used for a kernel estimator with given points and weights.

Usage

1
bwd.nrd(x, w=replicate(length(x),1), d = 2)

Arguments

x

numeric vector: sample points to be used for a normal kernel estimator.

w

numeric vector of the same length of x: weights to give to the elements of x. Default is a vector of ones

d

number of dimensions of the kernel estimator.

Details

Computes the optimal bandwidth with the Silverman rule, for a kernel estimator with points x and weights w. If a multivariate kernel is used, (i.e. d > 1), bwd.nrd must be called for each variable. It computes dispersion only with the weighted standard deviation, with no robust alternative. Called by kde2dnew.fortran.

Value

The value of the bandwidth for a sample x and weights w.

Note

It is used in connection with the the declustering method of etasFLP. Points with an higher probability of being part of the background seismicity will weight more in the estimation of the background seismicity.

Note

This is a slight modification of bw.nrd.

Author(s)

Marcello Chiodi

References

Silverman, B.W. (1986). Density Estimation for Statistics and Data Analysis. Chapman and Hall: London.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
## The function is currently defined as
function (x,w=replicate(length(x),1),d=2) 
{
    if (length(x) < 2L) 
        stop("need at least 2 data points")
     m<-weighted.mean(x,w) 
     return(sqrt(weighted.mean((x-m)^2,w)) * 
	      (length(x)*(d+2)/4)^(-1/(d+4)))
}

## End(Not run)

Example output

Loading required package: mapdata
Loading required package: maps
Loading required package: rgl
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 
function (x, w = replicate(length(x), 1), d = 2) 
{
    if (length(x) < 2L) 
        stop("need at least 2 data points")
    m <- weighted.mean(x, w)
    return(sqrt(weighted.mean((x - m)^2, w)) * (length(x) * (d + 
        2)/4)^(-1/(d + 4)))
}

etasFLP documentation built on May 1, 2019, 6:48 p.m.