# NOT RUN {
### Examples for PLS-DA results class
library(mdatools)
## 1. Make a PLS-DA model with full cross-validation, get
## calibration results and show overview
# make a calibration set from iris data (3 classes)
# use names of classes as class vector
x.cal = iris[seq(1, nrow(iris), 2), 1:4]
c.cal = iris[seq(1, nrow(iris), 2), 5]
model = plsda(x.cal, c.cal, ncomp = 3, cv = 1, info = 'IRIS data example')
model = selectCompNum(model, 1)
res = model$calres
# show summary and basic plots for calibration results
summary(res)
plot(res)
## 2. Apply the calibrated PLS-DA model to a new dataset
# make a new data
x.new = iris[seq(2, nrow(iris), 2), 1:4]
c.new = iris[seq(2, nrow(iris), 2), 5]
res = predict(model, x.new, c.new)
summary(res)
plot(res)
## 3. Show performance plots for the results
par(mfrow = c(2, 2))
plotSpecificity(res)
plotSensitivity(res)
plotMisclassified(res)
plotMisclassified(res, nc = 2)
par(mfrow = c(1, 1))
## 3. Show both class and y values predictions
par(mfrow = c(2, 2))
plotPredictions(res)
plotPredictions(res, ncomp = 2, nc = 2)
plotPredictions(structure(res, class = "plsres"))
plotPredictions(structure(res, class = "plsres"), ncomp = 2, ny = 2)
par(mfrow = c(1, 1))
## 4. All plots from ordinary PLS results can be used, e.g.:
par(mfrow = c(2, 2))
plotXYScores(res)
plotYVariance(res, type = 'h')
plotXVariance(res, type = 'h')
plotXResiduals(res)
par(mfrow = c(1, 1))
# }
Run the code above in your browser using DataLab