Learn R Programming

kerndwd (version 1.0.1)

predict.kerndwd: use DWD to predict class labels for new observations

Description

Predict the binary class labels or the fitted values of an kerndwd object.

Usage

## S3 method for class 'kerndwd':
predict(object, kern, x, newx, type=c("class", "link"), ...)

Arguments

object
A fitted kerndwd object.
kern
The kernel function used when fitting the kerndwd object.
x
The predictor matrix, i.e., the x matrix used when fitting the kerndwd object.
newx
A matrix of new values for x at which predictions are to be made. We note that newx must be a matrix, predict function does not accept a vector or other formats of newx.
type
"class" or "link"? "class" produces the predicted binary class labels and "link" returns the fitted values. Default is "class".
...
Not used. Other arguments to predict.

Value

  • Returns either the predicted class labels or the fitted values, depending on the choice of type.

Details

If "type" is "class", the function returns the predicted class labels. If "type" is "link", the result is $\beta_0 + x_i'\beta$ for the linear case and $\beta_0 + K_i'\alpha$ for the kernel case.

References

Wang, B. and Zou, H. (2015) ``Another Look at DWD: Thrifty Algorithm and Bayes Risk Consistency in RKHS". http://arxiv.org/abs/1508.05913v1.pdf

See Also

kerndwd

Examples

Run this code
data(Haberman)
Haberman$X = scale(Haberman$X, center=TRUE, scale=TRUE)
lambda = 10^(seq(-3, 3, length.out=10))
kern = rbfdot(sigma=1)
m1 = kerndwd(Haberman$X, Haberman$y, kern, qval=1, 
  lambda=lambda, eps=1e-5, maxit=1e5)
predict(m1, kern, Haberman$X, tail(Haberman$X))

Run the code above in your browser using DataLab