glmNet | R Documentation |
Fit a generalized linear model or Cox model via the cyclic coordinate descent algorithm using the functions
glmnet
and cv.glmnet
in the package glmnet.
glmNet(x, y, family = c("gaussian", "binomial", "poisson", "cox"), offset = NULL,
alpha = c(1, 0.5, 0), lambda,
penalty.factor = rep(1, ncol(x)), nfolds = 10, ncv = 10,
verbose = FALSE)
x , y , family , offset , alpha , lambda , penalty.factor , nfolds |
These arguments are the same as in the functions |
ncv |
repeated number of cross-validation. |
verbose |
logical. If |
The function cv.glmnet
performs cross-validation to determine an optimal penalty lambda
.
Since the folds are selected at random, the estimate of the optimal penalty is not stable and depends on the folds.
This function does K-fold cross-validation ncv
times and uses the mean of the ncv
penalty values as the estimate of the optimal penalty lambda
,
and then fits the elastic net model (including lasso and ridge) using the optimal penalty lambda
.
This function returns all outputs from the function glmnet
, and also prior.scale
, which can be used in Bayesian hierarchical models.
Nengjun Yi, nyi@uab.edu
Friedman, J., Hastie, T. and Tibshirani, R. (2010) Regularization Paths for Generalized Linear Models via Coordinate Descent. J Stat Softw 33, 1-22.
Simon, N., Friedman, J., Hastie, T. & Tibshirani, R. (2011) Regularization Paths for Cox's Proportional Hazards Model via Coordinate Descent. Journal of Statistical Software 39, 1-13.
glmnet
, bmlasso
, cv.glmnet
see examples in bmlasso
and cv.bh
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.