kernel functions {kerndwd} | R Documentation |
Kernel Functions
Description
Kernel functions provided in the R package kernlab
. Details can be seen in the reference below.
The Gaussian RBF kernel k(x,x') = \exp(-\sigma \|x - x'\|^2)
The Polynomial kernel k(x,x') = (scale <x, x'> + offset)^{degree}
The Linear kernel k(x,x') = <x, x'>
The Laplacian kernel k(x,x') = \exp(-\sigma \|x - x'\|)
The Bessel kernel k(x,x') = (- \mathrm{Bessel}_{(\nu+1)}^n \sigma \|x - x'\|^2)
The ANOVA RBF kernel k(x,x') = \sum_{1\leq i_1 \ldots < i_D \leq N}
\prod_{d=1}^D k(x_{id}, {x'}_{id})
where k(x, x) is a Gaussian RBF kernel.
The Spline kernel \prod_{d=1}^D 1 + x_i x_j + x_i x_j \min(x_i,
x_j) - \frac{x_i + x_j}{2} \min(x_i,x_j)^2 +
\frac{\min(x_i,x_j)^3}{3}
.
The parameter sigma
used in rbfdot
can be selected by sigest()
.
Usage
rbfdot(sigma = 1)
polydot(degree = 1, scale = 1, offset = 1)
vanilladot()
laplacedot(sigma = 1)
besseldot(sigma = 1, order = 1, degree = 1)
anovadot(sigma = 1, degree = 1)
splinedot()
sigest(x)
Arguments
sigma |
The inverse kernel width used by the Gaussian, the Laplacian, the Bessel, and the ANOVA kernel. |
degree |
The degree of the polynomial, bessel or ANOVA kernel function. This has to be an positive integer. |
scale |
The scaling parameter of the polynomial kernel function. |
offset |
The offset used in a polynomial kernel. |
order |
The order of the Bessel function to be used as a kernel. |
x |
The design matrix used in |
Details
These R functions and descriptions are directly duplicated and/or adapted from the R package kernlab
.
Value
Return an S4 object of class kernel
which can be used as the argument of kern
when fitting a kerndwd
model.
References
Wang, B. and Zou, H. (2018)
“Another Look at Distance Weighted Discrimination,"
Journal of Royal Statistical Society, Series B, 80(1), 177–198.
https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12244
Karatzoglou, A., Smola, A., Hornik, K., and Zeileis, A. (2004)
“kernlab – An S4 Package for Kernel Methods in R",
Journal of Statistical Software, 11(9), 1–20.
https://www.jstatsoft.org/v11/i09/paper
Examples
data(BUPA)
# generate a linear kernel
kfun = vanilladot()
# generate a Laplacian kernel function with sigma = 1
kfun = laplacedot(sigma=1)
# generate a Gaussian kernel function with sigma estimated by sigest()
kfun = rbfdot(sigma=sigest(BUPA$X))
# set kern=kfun when fitting a kerndwd object
data(BUPA)
BUPA$X = scale(BUPA$X, center=TRUE, scale=TRUE)
lambda = 10^(seq(-3, 3, length.out=10))
m1 = kerndwd(BUPA$X, BUPA$y, kern=kfun,
qval=1, lambda=lambda, eps=1e-5, maxit=1e5)