kqr
performs
non-parametric Quantile Regression."kqr"(x, data=NULL, ..., subset, na.action = na.omit, scaled = TRUE)
"kqr"(x,...)
"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)
"kqr"(x, y, tau = 0.5, C = 0.1, fit = TRUE, cross = 0)
"kqr"(x, y, tau = 0.5, C = 0.1, kernel = "strigdot", kpar= list(length=4, C=0.5), fit = TRUE, cross = 0)
kernelMatrix
of the training data or a list of character vectors (for use
with the string kernel). Note, that the intercept is always
excluded, whether given in the formula or not.kqr
is called from.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
and y
variables) to zero mean and unit variance. The center and scale
values are returned and used for later predictions. (default: TRUE)kernlab
provides the most popular kernel functions
which can be used by setting the kernel parameter to the following
strings:
rbfdot
Radial Basis kernel function "Gaussian"
polydot
Polynomial kernel function
vanilladot
Linear kernel function
tanhdot
Hyperbolic tangent kernel function
laplacedot
Laplacian kernel function
besseldot
Bessel kernel function
anovadot
ANOVA RBF kernel function
splinedot
Spline kernel
stringdot
String kernel
The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument.
sigma
inverse kernel width for the Radial Basis
kernel function "rbfdot" and the Laplacian kernel "laplacedot".
degree, scale, offset
for the Polynomial kernel "polydot"
scale, offset
for the Hyperbolic tangent kernel
function "tanhdot"
sigma, order, degree
for the Bessel kernel "besseldot".
sigma, degree
for the ANOVA kernel "anovadot".
lenght, lambda, normalized
for the "stringdot" kernel
where length is the length of the strings considered, lambda the
decay factor and normalized a logical parameter determining if the
kernel evaluations should be normalized.
Hyper-parameters for user defined kernels can be passed
through the kpar
parameter as well. In the case of a Radial
Basis kernel function (Gaussian) kpar can also be set to the
string "automatic" which uses the heuristics in 'sigest' to
calculate a good 'sigma' value for the Gaussian RBF or
Laplace kernel, from the data. (default = "automatic").
kqr
with large datasets since normally an n times n
kernel matrix would be computed. Setting reduced
to TRUE
makes use of csi
to compute a decomposed form instead and
thus only a $n \times m$ matrix where $m < n$ and $n$ the sample size is
stored in memory (default: FALSE)reduced
is TRUE
(default :
dim(x)[1]/6)NA
s 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 causes an error if NA
cases are found. (NOTE: If given, this argument must be named.)kqr
containing the fitted model along with
information.Accessor functions can be used to access the slots of the
object which include :
coef
.kqr-class
for more details.
ipop
implemented in kernlab
.
predict.kqr
, kqr-class
, ipop
, rvm
, ksvm
# 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 DataLab