Learn R Programming

mdatools (version 0.14.2)

simcam: SIMCA multiclass classification

Description

simcam is used to combine several one-class SIMCA models for multiclass classification.

Usage

simcam(models, info = "")

Value

Returns an object of simcam class with following fields:

models

a list with provided SIMCA models.

dispower

an array with discrimination power of variables for each pair of individual models.

moddist

a matrix with distance between each each pair of individual models.

classnames

vector with names of individual classes.

nclasses

number of classes in the object.

info

information provided by user when create the object.

calres

an object of class simcamres with classification results for a calibration data.

Arguments

models

list with SIMCA models (simca objects).

info

optional text with information about the the object.

Details

Besides the possibility for multiclass classification, SIMCAM also provides tools for investigation of relationship among individual models (classes), such as discrimination power of variables, Cooman's plot, model distance, etc.

When create simcam object, the calibration data from all individual SIMCA models is extracted and combined for making predictions and calculate performance of the multi-class model. The results are stored in $calres field of the model object.

See Also

Methods for simca objects:

print.simcamshows information about the object.
summary.simcamshows summary statistics for the models.
plot.simcammakes an overview of SIMCAM model with two plots.
predict.simcamapplies SIMCAM model to a new data.
plotModelDistance.simcamshows plot with distance between individual models.
plotDiscriminationPower.simcamshows plot with discrimination power.
plotCooman.simcamshows Cooman's plot for calibration data.

Methods, inherited from classmodel class:

plotPredictions.classmodelshows plot with predicted values.
plotSensitivity.classmodelshows sensitivity plot.
plotSpecificity.classmodelshows specificity plot.
plotMisclassified.classmodelshows misclassified ratio plot.

Since SIMCAM objects and results are calculated only for optimal number of components, there is no sense to show such plots like sensitivity or specificity vs. number of components. However they are available as for any other classification model.

Examples

Run this code
## make a multiclass SIMCA model for Iris data
library(mdatools)

# split data
caldata = iris[seq(1, nrow(iris), 2), 1:4]
x.se = caldata[1:25, ]
x.ve = caldata[26:50, ]
x.vi = caldata[51:75, ]

x.test = iris[seq(2, nrow(iris), 2), 1:4]
c.test = iris[seq(2, nrow(iris), 2), 5]

# create individual models
m.se = simca(x.se, classname = "setosa")
m.se = selectCompNum(m.se, 1)

m.vi = simca(x.vi, classname = "virginica")
m.vi = selectCompNum(m.vi, 2)

m.ve = simca(x.ve, classname = "versicolor")
m.ve = selectCompNum(m.ve, 1)

# combine models into SIMCAM objects, show statistics and plots
m = simcam(list(m.se, m.vi, m.ve), info = "simcam model for Iris data")
summary(m)

# show predictions and residuals for calibration data
par(mfrow = c(2, 2))
plotPredictions(m)
plotCooman(m, nc = c(1, 2))
plotModelDistance(m, nc = 1)
plotDiscriminationPower(m, nc = c(1, 2))
par(mfrow = c(1, 1))

# apply the SIMCAM model to test set and show statistics and plots
res = predict(m, x.test, c.test)
summary(res)
plotPredictions(res)

Run the code above in your browser using DataLab