Learn R Programming

parcor (version 0.2-6)

mylars: Cross-validation for Lasso

Description

This function computes the cross-validation-optimal regression coefficients for lasso.

Usage

mylars(X, y, k = 10,use.Gram=TRUE,normalize=TRUE,intercept=TRUE)

Arguments

X
matrix of observations. The rows of X contain the samples, the columns of X contain the observed variables
y
vector of responses. The length of y must equal the number of rows of X
k
the number of splits in k-fold cross-validation. Default is k=10.
use.Gram
When the number of variables is very large, you may not want LARS to precompute the Gram matrix. Default is use.Gram=TRUE.
normalize
Should the columns of X be scaled? Default is normalize=TRUE.
intercept
Should an intercept be included? Default is intercept=TRUE.

Value

lambda
vector of paramter values from which the optimal parameter is selected
cv
cross-validated error for all lambda values
lambda.opt
cross-validation optimal parameter
cv.lasso
cv error for the optimal model.
intercept
cross-validation optimal intercept. If intercept=FALSE was specified, the intercept is set to 0.
coefficients
cross-validation optimal regression coefficients, without intercept

Details

We use the glmnet() function from the glmnet package to compute the fit. Note that in Kraemer et. al. (2009), we used the lars() function from the lars package, which is much slower than glmnet().

References

R. Tibshirani (1997) "Regression Shrinkage and Selection via the Lasso", Journal of the Royal Statistical Society B, 58 (1)

N. Kraemer, J. Schaefer, A.-L. Boulesteix (2009) "Regularized Estimation of Large-Scale Gene Regulatory Networks with Gaussian Graphical Models", BMC Bioinformatics, 10:384

http://www.biomedcentral.com/1471-2105/10/384/

See Also

Beta2parcor, adalasso

Examples

Run this code

n<-20
p<-50
X<-matrix(rnorm(n*p),ncol=p)
y<-rnorm(n)
dummy<-mylars(X,y)

Run the code above in your browser using DataLab