| cvMclustDA | R Documentation |
V-fold cross-validation for classification models based on Gaussian finite mixture modelling.
cvMclustDA(object, nfold = 10,
prop = object$prop,
verbose = interactive(),
...)
object |
An object of class |
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 |
... |
Further arguments passed to or from other methods. |
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).
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. |
Luca Scrucca
MclustDA,
predict.MclustDA,
classError,
BrierScore
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.