Learn R Programming

mclust (version 6.0.0)

cvMclustDA: MclustDA cross-validation

Description

V-fold cross-validation for classification models based on Gaussian finite mixture modelling.

Usage

cvMclustDA(object, nfold = 10, 
           prop = object$prop,
           verbose = interactive(), 
           ...)

Value

The function returns a list with the following components:

classification

a factor of cross-validated class labels.

z

a matrix containing the cross-validated probabilites for class assignment.

ce

the cross-validation classification error.

se.ce

the standard error of the cross-validated classification error.

brier

the cross-validation Brier score.

se.brier

the standard error of the cross-validated Brier score.

Arguments

object

An object of class 'MclustDA' resulting from a call to MclustDA.

nfold

An integer specifying the number of folds (by defaul 10-fold CV is used).

prop

A vector of class prior probabilities, which if not provided default to the class proportions in the training data.

verbose

A logical controlling if a text progress bar is displayed during the cross-validation procedure. By default is TRUE if the session is interactive, and FALSE otherwise.

...

Further arguments passed to or from other methods.

Author

Luca Scrucca

Details

The function implements V-fold cross-validation for classification models fitted by MclustDA. Classification error and Brier score are the metrics returned, but other metrics can be computed using the output returned by this function (see Examples section below).

See Also

MclustDA, predict.MclustDA, classError, BrierScore

Examples

Run this code
# \donttest{
# Iris data
Class <- iris$Species
X <- iris[,1:4]

## EDDA model with common covariance (essentially equivalent to linear discriminant analysis)
irisEDDA <- MclustDA(X, Class, modelType = "EDDA", modelNames = "EEE")
cv <- cvMclustDA(irisEDDA)                         # 10-fold CV (default)
str(cv)
cv <- cvMclustDA(irisEDDA, nfold = length(Class))  # LOO-CV
str(cv)

## MclustDA model selected by BIC
irisMclustDA <- MclustDA(X, Class)
cv <- cvMclustDA(irisMclustDA)                     # 10-fold CV (default)
str(cv)

# Banknote data
data("banknote")
Class <- banknote$Status
X <- banknote[,2:7]

## EDDA model selected by BIC
banknoteEDDA <- MclustDA(X, Class, modelType = "EDDA")
cv <- cvMclustDA(banknoteEDDA)                     # 10-fold CV (default)
str(cv)

(ConfusionMatrix <- table(Pred = cv$classification, Class))
TP <- ConfusionMatrix[1,1]
FP <- ConfusionMatrix[1,2]
FN <- ConfusionMatrix[2,1]
TN <- ConfusionMatrix[2,2]
(Sensitivity <- TP/(TP+FN))
(Specificity <- TN/(FP+TN))
# }

Run the code above in your browser using DataLab