wfs: Generation of Window Functions

Description Usage Arguments Details Value See Also Examples

Description

The window functions generating functions that are used in various local classification methods.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
biweight(bw, k)

cauchy(bw, k, nn.only = TRUE)

cosine(bw, k)

epanechnikov(bw, k)

exponential(bw, k, nn.only = TRUE)

gaussian(bw, k, nn.only = TRUE)

optcosine(bw, k)

rectangular(bw, k)

triangular(bw, k)

Arguments

bw

The bandwidth parameter.

k

The number of nearest neighbors.

nn.only

(Logical. Only required for window functions with infinite support.) Should only the k nearest neighbors or all observations receive positive weights? Defaults to TRUE.

Details

These functions are used to initialize window functions that can be passed as wf argument to various local classification methods.

If only bw is given a window function with fixed bandwidth is returned.

If only k is given a window function with k nearest neighbors bandwidth, i.e. adaptive to the local density of data points, is generated. In case of window functions with infinite support, "cauchy", "exponential" and "gaussian", the argument nn.only is used to decide if only the k nearest neighbors or all observations receive positive weights.

If bw and k are both specified, a window function with fixed bandwidth is generated and all weights are set to zero except for the k nearest neighbors.

Parts of the source code are based on the function density in package stats. Concerning the "cosine" and "optcosine" windows, it applies the same as for density: "cosine" is smoother than "optcosine", which is the usual 'cosine' kernel in the literature. "cosine" is the version used by the S programming language.

Value

Returns an object of class "function". The resulting function implements the desired window function and depends on one argument x that is usually some sort of distance (and assumed to be positive). The returned function has several attributes, depending on which arguments are specified.

"name"

The name of the window function.

"bw"

(If the corresponding argument is given.) The chosen bandwidth.

"k"

(If the corresponding argument is given.) The chosen number of nearest neighbors.

"nn.only"

(Logical. Only if k was specified.) TRUE if only the k nearest neighbors are used. (nn.only is always TRUE except for window functions with infinite support.)

"adaptive"

(Logical.) TRUE in case of an adaptive bandwidth, FALSE if the bandwidth is fixed.

See Also

Documentation of various local classification methods, e.g. dalda or oslda, and density.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
x <- seq(0,1,0.01)

## fixed bandwidth
gwf <- gaussian(bw = 1)
gwf
curve(gwf(x))

## adaptive bandwidth, only the 50 nearest neighbors receive positive weights
gwf <- gaussian(k = 50)
gwf
curve(gwf(x))

## adaptive bandwidth, all observations have positive weights
gwf <- gaussian(k = 50, nn.only = FALSE)
gwf
curve(gwf(x))

## fixed bandwidth, only the 100 nearest neighbors get positive weights
gwf <- gaussian(k = 50, bw = 1)
gwf
curve(gwf(x))

schiffner/locClass documentation built on May 29, 2019, 3:39 p.m.