vcr.da.newdata: Carry out discriminant analysis on new data, and prepare to...

View source: R/VCR_DA.R

vcr.da.newdataR 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 NA for some or all cases. If NULL, is assumed to be NA everywhere.

vcr.da.train.out

output of vcr.da.train on the training data.

Value

A list with components:

yintnew

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

ynew

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

levels

levels of the response, from vcr.da.train.out.

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 NA for cases whose ynew is missing.

altlab

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

PAC

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

fig

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

farness

farness of each case i from its given class. Is NA for cases whose ynew 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, from vcr.da.train.out.

lCurrent

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

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 ynew.

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. \Sexpr[results=rd]{tools:::Rd_expr_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)

classmap documentation built on April 23, 2023, 5:09 p.m.