Description Usage Arguments Details Value See Also Examples
The window function generating functions that are used in various local classification methods.
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)
|
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 |
The window function generating functions are used to
initialize a window function. These functions 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 what is said in the documentation of
density: "cosine"
is smoother than
"optcosine"
, which is the usual 'cosine' kernel in
the literature. "cosine"
is the version used by S.
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. The returned function has
several attributes, depending on which arguments are
specified.
"name"
The name of the window function.
"bw"
(If corresponding argument is given.) The chosen bandwidth.
"k"
(If 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.
Documentation for various local classification methods,
e.g. dalda
or oslda
, and
density.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## fixed bandwidth
gwf <- gaussian(bw = 1)
gwf
## adaptive bandwidth, only the 100 nearest neighbors receive positive weights
gwf <- gaussian(k = 100)
gwf
gwf(1:150)
## adaptive bandwidth, all observations have positive weights
gwf <- gaussian(k = 100, nn.only = FALSE)
gwf
gwf(1:150)
## fixed bandwidth, only the 100 nearest neighbors get positive weights
gwf <- gaussian(k = 100, bw = 1)
gwf
gwf(1:150)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.