cv.krome: Cross-validation for krome

Description Usage Arguments Details Value References Examples

View source: R/cv.krome.R

Description

Does k-fold cross-validation for krome, and returns a value for lambda.

Usage

1
2
## S3 method for class 'krome'
cv(x, y, kern, lambda = NULL, nfolds = 5, foldid, delta = 2, ...)

Arguments

x

matrix of predictors, of dimension N*p; each row is an observation vector.

y

response variable.

kern

the built-in kernel classes in krome. The kern parameter can be set to any function, of class kernel, which computes the inner product in feature space between two vector arguments. krome provides the most popular kernel functions which can be initialized by using the following functions:

  • rbfdot Radial Basis kernel function,

  • 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 the Spline kernel.

Objects can be created by calling the rbfdot, polydot, tanhdot, vanilladot, anovadot, besseldot, laplacedot, splinedot functions etc. (see example.)

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.

nfolds

number of folds - default is 5. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3.

foldid

an optional vector of values between 1 and nfold identifying what fold each observation is in. If supplied, nfold can be missing.

delta

the parameter delta in the huber regression loss. The value must be positive. Default is 2.

...

other arguments that can be passed to krome.

Details

The function runs krome nfolds+1 times; the first to get the lambda sequence, and then the remainder to compute the fit with each of the folds omitted. The average error and standard deviation over the folds are computed.

Value

an object of class cv.krome is returned, which is a list with the ingredients of the cross-validation fit.

lambda

the values of lambda used in the fits.

cvm

the mean cross-validated error - a vector of length length(lambda).

cvsd

estimate of standard error of cvm.

cvupper

upper curve = cvm+cvsd.

cvlo

lower curve = cvm-cvsd.

name

a character string "Expectile Loss"

lambda.min

the optimal value of lambda that gives minimum cross validation error cvm.

cvm.min

the minimum cross validation error cvm.

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
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)

# set gaussian kernel 
kern <- rbfdot(sigma=0.1)

# define lambda sequence
lambda <- exp(seq(log(0.5),log(0.01),len=10))

cv.krome(x=X, y=Y, kern, lambda = lambda, nfolds = 5, delta = 2)

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