Learn R Programming

KSPM (version 0.2.1)

Kernel: Create a Kernel Object

Description

Create a kernel object, to use as variable in a model formula.

Usage

Kernel(x, kernel.function, scale = TRUE, rho = NULL, gamma = NULL,
  d = NULL)

Arguments

x

a formula, a vector or a matrix of variables grouped in the same kernel. It could also be a symetric matrix representing the Gram matrix, associated to a kernel function, already computed by the user.

kernel.function

type of kernel. Possible values are "gaussian", "linear", "polynomial", "sigmoid", "inverse.quadratic" or "equality". See details below. If x is a Gram matrix, associated to a kernel function, already computed by the user, kernel.function should be equal to "gram.matrix".

scale

boolean indicating if variables should be scaled before computing the kernel.

rho, gamma, d

kernel function hyperparameters. See details below.

Value

A Kernel object including all parameters needed in computation of the model

Details

To use inside kspm() function. Given two \(p-\)dimensional vectors \(x\) and \(y\),

  • the Gaussian kernel is defined as \(k(x,y) = exp\left(-\frac{\parallel x-y \parallel^2}{\rho}\right)\) where \(\parallel x-y \parallel\) is the Euclidean distance between \(x\) and \(y\) and \(\rho > 0\) is the bandwidth of the kernel,

  • the linear kernel is defined as \(k(x,y) = x^Ty\),

  • the polynomial kernel is defined as \(k(x,y) = (\rho x^Ty + \gamma)^d\) with \(\rho > 0\), \(d\) is the polynomial order. Of note, a linear kernel is a polynomial kernel with \(\rho = d = 1\) and \(\gamma = 0\),

  • the sigmoid kernel is defined as \(k(x,y) = tanh(\rho x^Ty + \gamma)\) which is similar to the sigmoid function in logistic regression,

  • the inverse quadratic function defined as \(k(x,y) = \frac{1}{\sqrt{\parallel x-y \parallel^2 + \gamma}}\) with \(\gamma > 0\),

  • the equality kernel defined as \(k(x,y) = \left\lbrace \begin{array}{ll} 1 & if x = y \\ 0 & otherwise \end{array}\right.\).

Of note, Gaussian, inverse quadratic and equality kernels are measures of similarity resulting to a matrix containing 1 along the diagonal.

References

Liu, D., Lin, X., and Ghosh, D. (2007). Semiparametric regression of multidimensional genetic pathway data: least squares kernel machines and linear mixed models. Biometrics, 63(4), 1079:1088.