Description Usage Arguments Details Value Author(s) References Examples
Does 2D k-fold cross-validation for KERE
, and returns the best value for lambda
and sigma
(for Gaussian and Laplace kernels) or scale
for Hyperbolic tanget kernel.
1 2 |
x |
matrix of predictors, of dimension N*p; each row is an observation vector. |
y |
response variable. |
kname |
the name of the kernel to be used. Currently
|
lambda |
a user supplied |
sigma |
a user supplied |
... |
other arguments that can be passed to |
The algorithm generates a 2D grid of (lambda
, sigma
) pairs from the user specified lambda
and sigma
sequences. Then for each pair, the function computes the corresponding averaged cross-validation errors. The values and locations of the optimal lambda
and sigma
that give the smallest error are return, as well as the whole 2D grid of cross-validation errors.
an object of class cv2d.KERE
is returned, which is a
list with the ingredients of the cross-validation fit.
out_mat |
2D grid of cross validation errors for ( |
mm.cvm |
the optimal value of cross validation error |
loc.lambda |
the location of the optimal lambda |
loc.sigma |
the location of the optimal sigma |
mm.lambda |
the optimal lambda value |
mm.sigma |
the optimal sigma value |
Yi Yang, Teng Zhang and Hui Zou
Maintainer: Yi Yang <yi.yang6@mcgill.ca>
Y. Yang, T. Zhang, and H. Zou. (2017) "Flexible Expectile Regression in Reproducing Kernel Hilbert Space." Technometrics. Accepted.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # generate data
N <- 200
X1 <- runif(N)
X2 <- 2*runif(N)
X3 <- 3*runif(N)
SNR <- 10 # signal-to-noise ratio
Y <- X1**1.5 + 2 * (X2**.5) + X1*X3
sigma <- sqrt(var(Y)/SNR)
Y <- Y + X2*rnorm(N,0,sigma)
X <- cbind(X1,X2,X3)
# define lambda and sigma sequence
lambda <- exp(seq(log(1),log(0.1),len=10))
sigma <- exp(seq(log(0.01),log(0.001),len=10))
# perform 2D CV
cv1 <- cv2d.KERE(X, Y,
"rbfdot",
lambda = lambda, sigma = sigma,
eps = 1e-6, maxit = 500,
omega = 0.5, gamma = 1e-06)
cat("\n loc.lambda \n ", cv1$loc.lambda)
cat("\n loc.sigma \n ",cv1$loc.sigma)
# use optimal (lambda,sigma) to refit
kern <- rbfdot(sigma=cv1$mm.sigma)
m1 <- KERE(X, Y,
kern,
lambda = cv1$mm.lambda,
eps = 1e-6, maxit = 500,
omega = 0.5, gamma = 1e-06)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.