kqr {kernlab} | R Documentation |
Kernel Quantile Regression.
Description
The Kernel Quantile Regression algorithm kqr
performs
non-parametric Quantile Regression.
Usage
## S4 method for signature 'formula'
kqr(x, data=NULL, ..., subset, na.action = na.omit, scaled = TRUE)
## S4 method for signature 'vector'
kqr(x,...)
## S4 method for signature '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)
## S4 method for signature 'kernelMatrix'
kqr(x, y, tau = 0.5, C = 0.1, fit = TRUE, cross = 0)
## S4 method for signature '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 |
data |
an optional data frame containing the variables in the model.
By default the variables are taken from the environment which
|
y |
a numeric vector or a column matrix containing the response. |
scaled |
A logical vector indicating the variables to be
scaled. If |
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.
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument. |
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 :
Hyper-parameters for user defined kernels can be passed
through the |
reduced |
use an incomplete cholesky decomposition to calculate a
decomposed form |
rank |
the rank m of the decomposed matrix calculated when using an
incomplete cholesky decomposition. This parameter is only
taken into account when |
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 |
... |
additional parameters. |
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
.
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 :
alpha |
The resulting model parameters which can be also accessed
by |
kernelf |
the kernel function used. |
error |
Training error (if fit == TRUE) |
see kqr-class
for more details.
Author(s)
Alexandros Karatzoglou
alexandros.karatzoglou@ci.tuwien.ac.at
References
Ichiro Takeuchi, Quoc V. Le, Timothy D. Sears, Alexander J. Smola
Nonparametric Quantile Estimation
Journal of Machine Learning Research 7,2006,1231-1264
https://www.jmlr.org/papers/volume7/takeuchi06a/takeuchi06a.pdf
See Also
predict.kqr
, kqr-class
, ipop
, rvm
, ksvm
Examples
# 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]