cv.msda {msda} | R Documentation |
Cross-validation for msda
Description
Does k-fold cross-validation for msda, returns a value for lambda
.
Usage
cv.msda(x, y, nfolds = 5, lambda = NULL, lambda.opt = "min", ...)
Arguments
x |
matrix of predictors, of dimension |
y |
response variable. This argument should be a factor for classification. |
nfolds |
number of folds - default is 5. Although |
lambda |
optional user-supplied lambda sequence; default is
|
lambda.opt |
If choose |
... |
other arguments that can be passed to msda. |
Details
The function runs msda
nfolds
+1 times; the
first to get the lambda
sequence, and then the remainder to
compute the fit with each of the folds omitted. The average error and standard deviation over the folds are computed.
Value
an object of class cv.msda
is returned, which is a
list with the ingredients of the cross-validation fit.
lambda |
the values of |
cvm |
the mean cross-validated error - a vector of length
|
cvsd |
estimate of standard error of |
lambda.min |
the optimal value of |
lambda.1se |
the largest value of |
msda.fit |
a fitted |
Author(s)
Qing Mai <mai@stat.fsu.edu>, Yi Yang <yi.yang6@mcgill.ca>, Hui Zou <hzou@stat.umn.edu>
Maintainer: Yi Yang <yi.yang6@mcgill.ca>
References
Mai, Q.*, Yang, Y.*, and Zou, H. (2014), "Multiclass Sparse Discriminant Analysis." Submitted to Journal of the American Statistical Association. (* co-first author)
URL: https://github.com/archer-yang-lab/msda
See Also
Examples
data(GDS1615)
x<-GDS1615$x
y<-GDS1615$y
obj.cv<-cv.msda(x=x,y=y,nfolds=5,lambda.opt="max")
lambda.min<-obj.cv$lambda.min
id.min<-which(obj.cv$lambda==lambda.min)
pred<-predict(obj.cv$msda.fit,x)[,id.min]