Learn R Programming

mdatools (version 0.5.3)

simcamres: Results of SIMCA multiclass classification

Description

simcamres is used to store results for SIMCA multiclass classification.

Usage

simcamres(cres, T2, Q2, T2lim, Q2lim)

Arguments

cres
results of classification (class classres).
T2
matrix with T2 values for each object and class.
Q2
matrix with Q2 values for each object and class.
T2lim
vector with T2 statistical limits for each class.
Q2lim
vector with Q2 statistical limits for each class.

Value

  • Returns an object (list) of class simcamres with the same fields as classres plus extra fields for Q2 and T2 values and limits:
  • c.predpredicted class values.
  • c.refreference (true) class values if provided.
  • T2matrix with T2 values for each object and class.
  • Q2matrix with Q2 values for each object and class.
  • T2limvector with T2 statistical limits for each class.
  • Q2limvector with Q2 statistical limits for each class.
  • The following fields are available only if reference values were provided.
  • tpnumber of true positives.
  • fpnmber of false positives.
  • fnnumber of false negatives.
  • specificityspecificity of predictions.
  • sensitivitysensitivity of predictions.

Details

Class simcamres inherits all properties and methods of class classres, plus store values necessary to visualise prediction decisions (e.g. Cooman's plot or Residuals plot).

In cotrast to simcares here only values for optimal (selected) number of components in each individual SIMCA models are presented.

There is no need to create a simcamres object manually, it is created automatically when make a SIMCAM model (see simcam) or apply the model to a new data (see predict.simcam). The object can be used to show summary and plots for the results.

See Also

Methods for simcamres objects: ll{ print.simcamres shows information about the object. summary.simcamres shows statistics for results of classification. plotResiduals.simcamres makes Q2 vs. T2 residuals plot. plotCooman.simcamres makes Cooman's plot. } Methods, inherited from classres class: ll{ showPredictions.classres show table with predicted values. plotPredictions.classres makes plot with predicted values. }

Check also simcam.

Examples

Run this code
## make a multiclass SIMCA model for Iris data and apply to test set
library(mdatools)

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

testdata = iris[seq(2, nrow(iris), 2), 1:4]
testdata.cref = iris[seq(2, nrow(iris), 2), 5]

# create individual models
semodel = simca(se, classname = 'setosa')
semodel = selectCompNum(semodel, 1)

vimodel = simca(vi, classname = 'virginica')
vimodel = selectCompNum(vimodel, 1)

vemodel = simca(ve, classname = 'versicolor')
vemodel = selectCompNum(vemodel, 1)

# combine models into SIMCAM object, show statistics 
model = simcam(list(semodel, vimodel, vemodel), info = 'Iris data')
res = predict(model, testdata, testdata.cref)
summary(res)

# show predicted values
showPredictions(res)

# plot predictions
par(mfrow = c(2, 2))
plotPredictions(res)
plotPredictions(res, nc = 1)
plotPredictions(res, nc = c(1, 2))
plotPredictions(res, show.labels = TRUE)
par(mfrow = c(1, 1))

# show residuals and Cooman's plot

par(mfrow = c(2, 2))
plotCooman(res)
plotCooman(res, nc = c(1, 3))
plotResiduals(res)
plotResiduals(res, nc = 3)
par(mfrow = c(1, 1))

Run the code above in your browser using DataLab