vcr.da.train {classmap}R Documentation

Carry out discriminant analysis on training data, and prepare to visualize its results.

Description

Custom DA function which prepares for graphical displays such as the classmap. The disciminant analysis itself is carried out by the maximum a posteriori rule, which maximizes the density of the mixture.

Usage

vcr.da.train(X, y, rule = "QDA", estmethod = "meancov")

Arguments

X

a numerical matrix containing the predictors in its columns. Missing values are not allowed.

y

a factor with the given class labels.

rule

either "QDA" for quadratic discriminant analysis or "LDA" for linear discriminant analysis.

estmethod

function for location and covariance estimation. Should return a list with the center $m and the covariance matrix $S. The default is "meancov" (classical mean and covariance matrix), and the option "DetMCD" (based on robustbase::covMcd) is also provided.

Value

A list with components:

yint

number of the given class of each case. Can contain NA's.

y

given class label of each case. Can contain NA's.

levels

levels of y

predint

predicted class number of each case. For each case this is the class with the highest posterior probability. Always exists.

pred

predicted label of each case.

altint

number of the alternative class. Among the classes different from the given class, it is the one with the highest posterior probability. Is NA for cases whose y is missing.

altlab

label of the alternative class. Is NA for cases whose y is missing.

PAC

probability of the alternative class. Is NA for cases whose y is missing.

figparams

parameters for computing fig, can be used for new data.

fig

distance of each case i from each class g. Always exists.

farness

farness of each case from its given class. Is NA for cases whose y is missing.

ofarness

for each case i, its lowest fig[i,g] to any class g. Always exists.

classMS

list with center and covariance matrix of each class

lCurrent

log of mixture density of each case in its given class. Is NA for cases with missing y.

lPred

log of mixture density of each case in its predicted class. Always exists.

lAlt

log of mixture density of each case in its alternative class. Is NA for cases with missing y.

Author(s)

Raymaekers J., Rousseeuw P.J.

References

Raymaekers J., Rousseeuw P.J., Hubert M. (2021). Class maps for visualizing classification results. Technometrics, appeared online. doi: 10.1080/00401706.2021.1927849(link to open access pdf)

See Also

vcr.da.newdata, classmap, silplot, stackedplot

Examples


data("data_floralbuds")
X <- data_floralbuds[, 1:6]; y <- data_floralbuds[, 7]
vcrout <- vcr.da.train(X, y, rule = "QDA")
# For linear discriminant analysis, put rule = "LDA".
confmat.vcr(vcrout) # There are a few outliers
cols <- c("saddlebrown", "orange", "olivedrab4", "royalblue3")
stackedplot(vcrout, classCols = cols)
classmap(vcrout, "bud", classCols = cols)

# For more examples, we refer to the vignette:
## Not run: 
vignette("Discriminant_analysis_examples")

## End(Not run)

[Package classmap version 1.2.3 Index]