easyLASSO: Select and fit sparse linear model with LASSO

Description Usage Arguments Value See Also Examples

View source: R/expandFunctions.R

Description

The purpose of this function is to make the process of LASSO modelling as simple as possible.

This is a simple wrapper on two glmnet functions which, when given input matrix X and response vector y, and a criterion for model selection, will estimate the lambda parameter, and return the LASSO results as a glmnet model. This model can then be used to find coefficients and predictions.

Usage

1
easyLASSO(X, y, criterion = "lambda.1se")

Arguments

X

Predictor matrix, nXp, with n observations and p features.

y

Response vector, or column or row matrix. Must have length n.

criterion

String describing which lambda criterion to use in selecting a LASSO model. Choices currently are c("lambda.1se","lambda.min").

Value

a glmnet model

See Also

glmnet and cv.glmnet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(1)
nObs <- 100
X <- distMat(nObs,6)
A <- cbind(c(1,0,-1,rep(0,3)))
  # Y will only depend on X[,1] and X[,3]
Y <- X %*% A + 0.1*rnorm(nObs)
lassoObj <- easyLASSO(X=X,y=Y) # LASSO fitting
Yhat <- predict(lassoObj,newx=X)
yyHatPlot(Y,Yhat)
coef( lassoObj ) # Sparse coefficients
coefPlot( lassoObj )

expandFunctions documentation built on May 2, 2019, 9:15 a.m.