Description Usage Arguments Value Examples
This function finds the lasso solution path for various values of the regularization parameter lambda using corrdinate descent. Returns a matrix containing the lasso solution vector beta for each regularization parameter.
1 | myLasso(X, Y, lambda_all)
|
X |
an n x p matrix of explanatory variables. |
Y |
n dimensional response vector |
lambda_all |
vector of regularization parameters |
Returns a p+1 x length of lambda_all matrix of regularized betas for each specified level of lambda
1 2 3 4 5 6 7 8 9 10 11 | dim_r=50
dim_c=10
s=7
lam = (100:1)*10
x = matrix(rnorm(dim_r*dim_c), nrow = dim_r)
beta_true = matrix(rep(0,dim_c), nrow = dim_c)
beta_true[1:s] = 1:7
y = x%*%beta_true + rnorm(dim_r)
beta_true <- c(0, beta_true)
lass <- myLasso(x, y, lam)
matplot(t(matrix(rep(1, 11), nrow = 1)%*%abs(lass)), t(lass), type = "l")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.