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 " |
estmethod |
function for location and covariance estimation.
Should return a list with the center |
Value
A list with components:
yint |
number of the given class of each case. Can contain |
y |
given class label of each case. Can contain |
levels |
levels of |
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 |
altlab |
label of the alternative class. Is |
PAC |
probability of the alternative class. Is |
figparams |
parameters for computing |
fig |
distance of each case |
farness |
farness of each case from its given class. Is |
ofarness |
for each case |
classMS |
list with center and covariance matrix of each class |
lCurrent |
log of mixture density of each case in its given class. Is |
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 |
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)