kernlab (version 0.9-7)

kqr: Kernel Quantile Regression.

Description

The Kernel Quantile Regression algorithm kqr performs non-parametric Quantile Regression.

Usage

## S3 method for class 'formula':
kqr(x, data=NULL, ..., subset, na.action = na.omit, scaled = TRUE)

## S3 method for class 'vector': kqr(x,...)

## S3 method for class 'matrix': kqr(x, y, scaled = TRUE, tau = 0.5, C = 0.1, kernel = "rbfdot", kpar = "automatic", reduced = FALSE, rank = dim(x)[1]/6, fit = TRUE, cross = 0, na.action = na.omit)

## S3 method for class 'kernelMatrix': kqr(x, y, tau = 0.5, C = 0.1, fit = TRUE, cross = 0)

## S3 method for class 'list': kqr(x, y, tau = 0.5, C = 0.1, kernel = "strigdot", kpar= list(length=4, C=0.5), fit = TRUE, cross = 0)

Arguments

x
e data or a symbolic description of the model to be fit. When not using a formula x can be a matrix or vector containing the training data or a kernel matrix of class kernelMatrix of the training data or a list of character vector
data
an optional data frame containing the variables in the model. By default the variables are taken from the environment which kqr is called from.
y
a numeric vector or a column matrix containing the response.
scaled
A logical vector indicating the variables to be scaled. If scaled is of length 1, the value is recycled as many times as needed and all non-binary variables are scaled. Per default, data are scaled internally (both x
tau
the quantile to be estimated, this is generally a number strictly between 0 and 1. For 0.5 the median is calculated. (default: 0.5)
C
the cost regularization parameter. This parameter controls the smoothness of the fitted function, essentially higher values for C lead to less smooth functions.(default: 1)
kernel
the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a dot product between two vector arguments. kernlab provides the most popular kernel functions which can
kpar
the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. Valid parameters for existing kernels are :
  • sigmainverse kernel width for the Radial Basis
reduced
use an incomplete cholesky decomposition to calculate a decomposed form $Z$ of the kernel Matrix $K$ (where $K = ZZ'$) and perform the calculations with $Z$. This might be useful when using kqr with large datasets since normally an n
rank
the rank m of the decomposed matrix calculated when using an incomplete cholesky decomposition. This parameter is only taken into account when reduced is TRUE(default : dim(x)[1]/6)
fit
indicates whether the fitted values should be computed and included in the model or not (default: 'TRUE')
cross
if a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the quality of the model: the Pinball loss and the for quantile regression
subset
An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.)
na.action
A function to specify the action to be taken if NAs are found. The default action is na.omit, which leads to rejection of cases with missing values on any required variable. An alternative is na.fail, which
...
additional parameters.

Value

  • An S4 object of class kqr containing the fitted model along with information.Accessor functions can be used to access the slots of the object which include :
  • alphaThe resulting model parameters which can be also accessed by coef.
  • kernelfthe kernel function used.
  • errorTraining error (if fit == TRUE)
  • see kqr-class for more details.

Details

In quantile regression a function is fitted to the data so that it satisfies the property that a portion $tau$ of the data $y|n$ is below the estimate. While the error bars of many regression problems can be viewed as such estimates quantile regression estimates this quantity directly. Kernel quantile regression is similar to nu-Support Vector Regression in that it minimizes a regularized loss function in RKHS. The difference between nu-SVR and kernel quantile regression is in the type of loss function used which in the case of quantile regression is the pinball loss (see reference for details.). Minimizing the regularized loss boils down to a quadratic problem which is solved using an interior point QP solver ipop implemented in kernlab.

References

Ichiro Takeuchi, Quoc V. Le, Timothy D. Sears, Alexander J. Smola Nonparametric Quantile Estimation Journal of Machine Learning Research 7,2006,1231-1264 http://www.jmlr.org/papers/volume7/takeuchi06a/takeuchi06a.pdf

See Also

predict.kqr, kqr-class, ipop, rvm, ksvm

Examples

Run this code
# create data
x <- sort(runif(300))
y <- sin(pi*x) + rnorm(300,0,sd=exp(sin(2*pi*x)))

# first calculate the median
qrm <- kqr(x, y, tau = 0.5, C=0.15)

# predict and plot
plot(x, y)
ytest <- predict(qrm, x)
lines(x, ytest, col="blue")

# calculate 0.9 quantile
qrm <- kqr(x, y, tau = 0.9, kernel = "rbfdot", kpar= list(sigma=10), C=0.15)
ytest <- predict(qrm, x)
lines(x, ytest, col="red")

# calculate 0.1 quantile
qrm <- kqr(x, y, tau = 0.1,C=0.15)
ytest <- predict(qrm, x)
lines(x, ytest, col="green")

# print first 10 model coefficients
coef(qrm)[1:10]

Run the code above in your browser using DataCamp Workspace