I am using LASSO from glmnet-package to create predictions. Furthermore, I am using cv.glmnet-function to do 5-fold cross-validation to create Lasso.fit. This glmnet-object is then used in predict-function, with the rule of thumb s = "lambda.1se".
x <- scale(x)
x_test <- scale(x_test)
lasso.fit <- cv.glmnet(x,y, nfolds = 5, alpha=1,
intercept =TRUE, standardize =TRUE, type.measure="mae")
lasso_pred <- predict(lasso.fit, x_test, s ="lambda.1se")
However, I am getting the following warning when running this model:
Warning:
from glmnet Fortran code (error code -79);
Convergence for 79th lambda value not reached after maxit=100000 iterations;
solutions for larger lambdas returned
What does this warning mean?
Moreover, should I take this warning seriously, i.e., changing something the cv.glmnet-function?
Or is this something that I should not be that worried when creating predictions with penalized methods?
By default, glmnet
tries to compute the solutions for 100 lambda values. The error is saying that at the 79th lambda value, the max iteration (10^5 by default) of coordinate descent was hit. Therefore, since the solution did not meet the convergence criterion, only the solutions for the first 78 lambda values are given. You can still use cv.glmnet
- it's just going to do model selection with those 78 lambdas. If you want to compute for more lambdas, simply pass another parameter maxit=...
where ...
is some number greater than 10^5.