cv.dLDA: Cross-validation for MGSDA

View source: R/cv.dLDA.R

cv.dLDAR Documentation

Cross-validation for MGSDA

Description

Chooses optimal tuning parameter lambda for function dLDA based on the m-fold cross-validation mean squared error

Usage

cv.dLDA(Xtrain, Ytrain, lambdaval = NULL, nl = 100, msep = 5, eps = 1e-6,
    l_min_ratio = ifelse(n<p,0.1,0.0001),myseed=NULL,prior=TRUE,rho=1)

Arguments

Xtrain

A Nxp data matrix; N observations on the rows and p features on the columns

Ytrain

A N vector containing the group labels. Should be coded as 1,2,...,G, where G is the number of groups

lambdaval

Optional user-supplied sequence of tuning parameters; the default value is NULL and cv.dLDA chooses its own sequence

nl

Number of lambda values; the default value is 50

msep

Number of cross-validation folds; the default value is 5

eps

Tolerance level for the convergence of the optimization algorithm; the default value is 1e-6

l_min_ratio

Smallest value for lambda, as a fraction of lambda.max, the data-derived value for which all coefficients are zero; the default value is 0.1 if the number of samples n is larger than the number of variables p, and is 0.001 otherwise.

myseed

Optional specification of random seed for generating the folds; the default value is NULL.

prior

A logical indicating whether to put larger weights to the groups of larger size; the default value is TRUE.

rho

A scalar that ensures the objective function is bounded from below; the default value is 1.

Value

lambdaval

The sequence of tuning parameters used

error_mean

The mean cross-validated number of misclassified observations - a vector of length length(lambdaval)

error_se

The standard error associated with each value of error_mean

lambda_min

The value of tuning parameter that has the minimal mean cross-validation error

f

The mean cross-validated number of non-zero features - a vector of length length(lambdaval)

Author(s)

Irina Gaynanova

References

I.Gaynanova, J.Booth and M.Wells (2016). "Simultaneous sparse estimation of canonical vectors in the p>>N setting", JASA, 111(514), 696-706.

Examples

### Example 1
n=10
p=100
G=3
ytrain=rep(1:G,each=n)
set.seed(1)
xtrain=matrix(rnorm(p*n*G),n*G,p)
# find optimal tuning parameter
out.cv=cv.dLDA(xtrain,ytrain)
# find V
V=dLDA(xtrain,ytrain,lambda=out.cv$lambda_min)
# number of non-zero features
sum(rowSums(V)!=0)

MGSDA documentation built on Sept. 4, 2023, 1:06 a.m.

Related to cv.dLDA in MGSDA...