cv2d.KERE: 2D Cross-validation for KERE

Description Usage Arguments Details Value Author(s) References Examples

Description

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.

Usage

1
2
## S3 method for class 'KERE'
cv2d(x, y, kname = c("rbfdot","laplacedot","tanhdot"), lambda = NULL, sigma = NULL, ...)

Arguments

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 cv2d.KERE only supports three kernels:

  • "rbfdot" Radial Basis kernel function,

  • "laplacedot" Laplacian kernel function,

  • "tanhdot" Hyperbolic tangent kernel function,

lambda

a user supplied lambda sequence. It is better to supply a decreasing sequence of lambda values, if not, the program will sort user-defined lambda sequence in decreasing order automatically.

sigma

a user supplied sigma sequence, as the parameters for the kernels.

...

other arguments that can be passed to KERE.

Details

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.

Value

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 (lambda, sigma) pairs

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

Author(s)

Yi Yang, Teng Zhang and Hui Zou
Maintainer: Yi Yang <yi.yang6@mcgill.ca>

References

Y. Yang, T. Zhang, and H. Zou. (2017) "Flexible Expectile Regression in Reproducing Kernel Hilbert Space." Technometrics. Accepted.

Examples

 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)	

emeryyi/KERE documentation built on May 16, 2019, 5:06 a.m.