require(lattice)
## validation for objects of class 'pls' or 'spls'
data(liver.toxicity)
X <- liver.toxicity$gene
Y <- liver.toxicity$clinic
liver.pls <- pls(X, Y, ncomp = 3)
liver.val <- valid(liver.pls, validation = "Mfold")
plot(liver.val, criterion = "R2", type = "l", layout = c(2, 2))
## validation for objects of class 'plsda' or 'splsda'
data(srbct)
X <- srbct$gene
Y <- srbct$class
ncomp = 5
srbct.splsda <- splsda(X, Y, ncomp = ncomp, keepX = rep(10, ncomp))
error <- valid(srbct.splsda, validation = "Mfold", folds = 5, method = "all")
plot(error, type = "l")
Run the code above in your browser using DataLab