# NOT RUN {
### Examples for PLS-DA model class
library(mdatools)
## 1. Make a PLS-DA model with full cross-validation and show model 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)
# show summary and basic model plots
# misclassification will be shown only for first class
summary(model)
plot(model)
# summary and model plots for second class
summary(model, nc = 2)
plot(model, nc = 2)
# summary and model plot for specific class and number of components
summary(model, nc = 3, ncomp = 3)
plot(model, nc = 3, ncomp = 3)
## 2. Show performance plots for a model
par(mfrow = c(2, 2))
plotSpecificity(model)
plotSensitivity(model)
plotMisclassified(model)
plotMisclassified(model, nc = 2)
par(mfrow = c(1, 1))
## 3. Show both class and y values predictions
par(mfrow = c(2, 2))
plotPredictions(model)
plotPredictions(model, res = 'calres', ncomp = 2, nc = 2)
plotPredictions(structure(model, class = "pls"))
plotPredictions(structure(model, class = "pls"), ncomp = 2, ny = 2)
par(mfrow = c(1, 1))
## 4. All plots from ordinary PLS can be used, e.g.:
par(mfrow = c(2, 2))
plotXYScores(model)
plotYVariance(model)
plotXResiduals(model)
plotRegcoeffs(model, ny = 2)
par(mfrow = c(1, 1))
# }
Run the code above in your browser using DataLab