vcr.da.newdata {classmap} | R Documentation |
Carry out discriminant analysis on new data, and prepare to visualize its results.
Description
Predicts class labels for new data by discriminant analysis, using the output of vcr.da.train
on the training data. For new data cases whose label in yintnew
is non-missing, additional output is produced for constructing graphical displays such as the classmap
.
Usage
vcr.da.newdata(Xnew, ynew=NULL, vcr.da.train.out)
Arguments
Xnew |
data matrix of the new data, with the same number of columns as in the training data. Missing values are not allowed. |
ynew |
factor with class membership of each new case. Can be |
vcr.da.train.out |
output of |
Value
A list with components:
yintnew |
number of the given class of each case. Can contain |
ynew |
given class label of each case. Can contain |
levels |
levels of the response, from |
predint |
predicted class number of each case. 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 |
fig |
distance of each case |
farness |
farness of each case |
ofarness |
For each case |
classMS |
list with center and covariance matrix of each class, from |
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.train
, classmap
, silplot
, stackedplot
Examples
vcr.train <- vcr.da.train(iris[, 1:4], iris[, 5])
inds <- c(51:150) # a subset, containing only 2 classes
iris2 <- iris[inds, ] # fake "new" data
iris2[c(1:10, 51:60), 5] <- NA
vcr.test <- vcr.da.newdata(iris2[, 1:4], iris2[, 5], vcr.train)
vcr.test$PAC[1:25] # between 0 and 1. Is NA where the response is.
plot(vcr.test$PAC, vcr.train$PAC[inds]); abline(0, 1) # match
plot(vcr.test$farness, vcr.train$farness[inds]); abline(0, 1) # match
confmat.vcr(vcr.train) # for comparison
confmat.vcr(vcr.test)
stackedplot(vcr.train) # for comparison
stackedplot(vcr.test)
classmap(vcr.train, "versicolor", classCols = 2:4) # for comparison
classmap(vcr.test, "versicolor", classCols = 2:4) # has fewer points
# For more examples, we refer to the vignette:
## Not run:
vignette("Discriminant_analysis_examples")
## End(Not run)