cv2d.krome: 2D Cross-validation for krome

Description Usage Arguments Details Value References Examples

View source: R/cv2d.krome.R

Description

Does 2D k-fold cross-validation for krome, 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 'krome'
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.krome 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 krome.

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.krome 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

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.krome(X, Y, 
		"rbfdot", 					     
		lambda = lambda, sigma = sigma, 
		eps = 1e-6, maxit = 500, 
		delta = 2, 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 <- krome(X, Y, 
kern, 					     
lambda = cv1$mm.lambda, 
eps = 1e-6, maxit = 500, 
delta = 0.5, gamma = 1e-06)	

emeryyi/rome documentation built on May 6, 2019, 9:53 a.m.