Description Usage Arguments Value See Also Examples

View source: R/expandFunctions.R

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.

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

`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"). |

a glmnet model

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 29, 2017, 11:38 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.