enetpath | R Documentation |
enethpath computes the elastic net (EN) regularization path (over grid of penalty parameter values). Uses pathwise CCD algorithm.
enetpath(y, X, alpha = 1, L = 100, eps = 1e-04, intcpt = TRUE, printitn = 0)
y |
: Numeric data vector of size N x 1 (output, respones) |
X |
: Nnumeric data matrix of size N x p. Each row represents one observation, and each column represents one predictor (feature). |
alpha |
: Numeric scalar, elastic net tuning parameter in the range [0,1]. If not given then use alpha = 1 (Lasso) |
L |
: Positive integer, the number of lambda values EN/Lasso uses. Default is L=100. |
intcpt: |
Logical flag to indicate if intercept is in the model. Default = True |
eps: |
Positive scalar, the ratio of the smallest to the largest Lambda value in the grid. Default is eps = 10^-4. |
printitn: |
print iteration number (default = 0, no printing) |
B : Fitted EN/Lasso regression coefficients, a p-by-(L+1) matrix, where p is the number of predictors (columns) in X, and L is the number of Lambda values. If intercept is in the model, then B is (p+1)-by-(L+1) matrix, with first element the intercept.
stats : list with following fields:
Lambda |
lambda parameters in ascending order |
MSE |
Mean squared error (MSE) |
BIC |
Bayesian information criterion values for each lambda |
file in Regression.R
y <- c(0.5377 , 1.8339 ,-2.2588 , 0.8622, 0.3188) x <- c(-1.3077 , -0.4336, 0.3426 , 3.5784, 2.7694) enetpath(y, matrix(c(x, x), nrow = 5, ncol = 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.