data(colon)
colon.x <- t(colon.x)
## divide the data set into a training set and a test
## set using a ratio of 2:1.
tr.index <- sample(1:62, 40)
fit <- rda(colon.x[, tr.index], colon.y[tr.index])
## predict the class labels of the test set at alpha=0.1
## and delta=0.5
ynew <- predict(fit, x=colon.x[, tr.index], y=colon.y[tr.index],
xnew=colon.x[, -tr.index], alpha=0.1, delta=0.5)
## calculate the prediction error
sum(ynew != colon.y[-tr.index])
Run the code above in your browser using DataLab