Learn R Programming

VDA (version 1.01)

cv.VDA_R: Choose $\lambda$ using K-fold cross validation

Description

Choose the optimal tuning parameter $\lambda$ for Vertex Discriminant Analyis by using K-fold cross validation.

Usage

cv.VDA_R(x, y, k, lam.vec)

Arguments

x
n x p matrix or data frame containing the cases for each feature. The rows correspond to cases and the columns to the features. Intercept column is not included in this.
y
n x 1 vector representing the outcome variable. Each element denotes which one of the k classes that case belongs to.
k
The number of folds to be used in cross-validation.
lam.vec
A vector containing the set of all values of $\lambda$, from which VDA will be conducted.

Value

  • kThe value of K used for the K-fold cross validation.
  • lam.vecThe values of lambda tested.
  • mean.errorThe mean error corresponding to each lambda across k-folds
  • lam.optThe determined lambda value among lam.vec that returns the smallest prediction error. This value is the optimal lambda value for use in link{VDA_R}.
  • error.cvThe prediction error matrix returned by cross validation method.

Details

K-fold cross validation to select optimal lambda for use in Vertex Disciminant Analysis (VDA_R). The optimal value is considered the lamda value that retuns the lowest testing error over the cross validation. If more than one lambda value give the minumum testing error, the largest lambda is selected.

A plot of the cross validation errors can be viewed through plot.cv.VDA_R.

References

Lange, K. and Wu, T.T. (2008) An MM Algorithm for Multicategory Vertex Discriminant Analysis. Journal of Computational and Graphical Statistics, Volume 17, No 3, 527-544.

See Also

VDA_R

plot.cv.VDA_R

Examples

Run this code
# load data
data(zoo)

# feature matrix without intercept
x <- zoo[,2:17]

# class vector
y <- zoo[,18]

# lambda vector
lam.vec <- (1:10)/10

# searching for the best lambda with 10-fold cross validation
obj <- cv.VDA_R(x, y, 10, lam.vec)

# run VDA
out <- VDA_R(x,y,obj$lam.opt)

Run the code above in your browser using DataLab