Similar to other predict methods, this functions predicts fitted values and class labels from a fitted KERE object.
Usage
## S3 method for class 'KERE'
predict(object, kern, x, newx,...)
Arguments
object
fitted KERE model object.
kern
the built-in kernel classes in KERE. Objects can be created by calling the rbfdot, polydot, tanhdot, vanilladot, anovadot, besseldot, laplacedot, splinedot functions etc. (see example.)
x
the original design matrix for training KERE.
newx
matrix of new values for x at which predictions are
to be made. NOTE: newx must be a matrix with each row as an observation. predict function does not accept a vector or other formats of newx.
...
other parameters to predict function.
Details
The fitted α_0 + K * α at newx is returned as a size nrow(newx)*length(lambda) matrix for various lambda values where the KERE model was fitted.
Value
The fitted α_0 + K * α is returned as a size nrow(newx)*length(lambda) matrix. The row represents the index for observations of newx. The column represents the index for the lambda sequence.
Author(s)
Yi Yang, Teng Zhang and Hui Zou
Maintainer: Yi Yang <yiyang@umn.edu>
References
Y. Yang, T. Zhang, and H. Zou. "Flexible Expectile Regression in Reproducing Kernel Hilbert Space." ArXiv e-prints: stat.ME/1508.05987, August 2015.
Examples
# create data
N <- 100
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))
# run KERE
m1 <- KERE(x=X, y=Y, kern=kern, lambda = lambda, omega = 0.5)
# create newx for prediction
N1 <- 5
X1 <- runif(N1)
X2 <- 2*runif(N1)
X3 <- 3*runif(N1)
newx <- cbind(X1,X2,X3)
# make prediction
p1 <- predict.KERE(m1, kern, X, newx)
p1
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(KERE)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/KERE/predict.KERE.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.KERE
> ### Title: make predictions from a "KERE" object.
> ### Aliases: predict.KERE
> ### Keywords: models regression
>
> ### ** Examples
>
> # create data
> N <- 100
> 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))
>
> # run KERE
> m1 <- KERE(x=X, y=Y, kern=kern, lambda = lambda, omega = 0.5)
>
> # create newx for prediction
> N1 <- 5
> X1 <- runif(N1)
> X2 <- 2*runif(N1)
> X3 <- 3*runif(N1)
> newx <- cbind(X1,X2,X3)
>
> # make prediction
> p1 <- predict.KERE(m1, kern, X, newx)
> p1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 2.634869 2.607706 2.598686 2.608253 2.632981 2.666868 2.703636 2.738677
[2,] 2.462555 2.435723 2.418147 2.407963 2.403069 2.401144 2.400110 2.398762
[3,] 2.249211 2.126263 2.031720 1.969740 1.937703 1.928633 1.934364 1.947865
[4,] 1.592921 1.453472 1.355226 1.298850 1.277085 1.277192 1.285018 1.288668
[5,] 1.680830 1.534723 1.419712 1.336491 1.281747 1.249724 1.233904 1.228224
[,9] [,10]
[1,] 2.769762 2.796608
[2,] 2.397092 2.396060
[3,] 1.964050 1.979488
[4,] 1.280444 1.257204
[5,] 1.227676 1.228503
>
>
>
>
>
> dev.off()
null device
1
>