cv.nfeaturesLDA: Cross-validation to find the optimum number of features...

Description Usage Arguments Details Value Author(s) References See Also

View source: R/cv.nfeaturesLDA.R

Description

This function provids an illustration of the process of finding out the optimum number of variables using k-fold cross-validation in a linear discriminant analysis (LDA).

Usage

1
2
3
4
5
6
7
8
cv.nfeaturesLDA(
  data = matrix(rnorm(600), 60),
  cl = gl(3, 20),
  k = 5,
  cex.rg = c(0.5, 3),
  col.av = c("blue", "red"),
  ...
)

Arguments

data

a data matrix containg the predictors in columns

cl

a factor indicating the classification of the rows of data

k

the number of folds

cex.rg

the range of the magnification to be used to the points in the plot

col.av

the two colors used to respectively denote rates of correct predictions in the i-th fold and the average rates for all k folds

...

arguments passed to points to draw the points which denote the correct rate

Details

For a classification problem, usually we wish to use as less variables as possible because of difficulties brought by the high dimension.

The selection procedure is like this:

Note that g_{max} is set by ani.options('nmax') (i.e. the maximum number of features we want to choose).

Value

A list containing

accuracy

a matrix in which the element in the i-th row and j-th column is the rate of correct predictions based on LDA, i.e. build a LDA model with j variables and predict with data in the i-th fold (the test set)

optimum

the optimum number of features based on the cross-validation

Author(s)

Yihui Xie <https://yihui.org/>

References

Examples at https://yihui.org/animation/example/cv-nfeatureslda/

Maindonald J, Braun J (2007). Data Analysis and Graphics Using R - An Example-Based Approach. Cambridge University Press, 2nd edition. pp. 400

See Also

kfcv, cv.ani, lda


animation documentation built on Oct. 7, 2021, 9:18 a.m.