cv.l1.reg {CDLasso}R Documentation

k-fold Cross Validation

Description

k-fold Cross Validation for L1 Greedy Coordinate Descent

Usage

cv.l1.reg(x, y, k, lam.vec)

Arguments

x

p x n design matrix - Note that the rows of X correspond to predictors and the columns to cases.

y

Outcome of length n

k

Number of folds for k-fold cross validation

lam.vec

Vector of penalization parameters

Details

K-fold cross validation to select optimal lambda for use in greedy coordinate descent for L1 regression l1.reg. The optimal value is considered the lambda value that retuns the lowest prediction error over the cross validation. If more than one lambda value give the minumum testing error, the smallest lambda is selected. Plot of the cross validation can be viewed through plot.cv.l1.reg

Value

k

The value of K used for the K-fold cross validation.

lam.vec

The values of lambda tested.

mean.error

The mean error corresponding to each lambda across k-folds

lam.opt

The determined lambda value among lam.vec that returns the smallest prediction error. This value is the optimal lambda value for use in l1.reg.

error.cv

The prediction error matrix returned by cross validation method.

num.pred

The number of predictors selected for the corresponding lambda during the cross validation.

Author(s)

Edward Grant, Kenneth Lange, Tong Tong Wu

Maintainer: Edward Grant edward.m.grant@gmail.com

References

Wu, T.T. and Lange, K. (2008). Coordinate Descent Algorithms for Lasso Penalized Regression. Annals of Applied Statistics, Volume 2, No 1, 224-244.

See Also

l1.reg

plot.cv.l1.reg

Examples

set.seed(6)
n=50 
p=200
nzfixed = c(1:5)
true.beta<-rep(0,p)
true.beta[nzfixed] = c(1,1,1,1,1)

x=matrix(rnorm(n*p),p,n)
y = t(x) %*% true.beta

rownames(x)<-1:nrow(x)
colnames(x)<-1:ncol(x)

crossval<-cv.l1.reg(x,y,10,(0:20)*2)
plot(crossval)
out<-l1.reg(x,y,lambda=crossval$lam.opt)
out

[Package CDLasso version 1.1 Index]