I assumed that cv.glmnet works as follows:
- Generate multiple glmnet fits for the entire data, presumably for automated lambda sequence using coordinate descent
- Use the lambdas gotten in step 1, and find rmse for different cross validation folds, again using glmnet
- The lambda with the best RMSE across folds is chosen as lambda_min
- Return the overall model (in step1) corresponding to lambda_min
But the github code (https://github.com/cran/glmnet/blob/master/R/cv.glmnet.R) suggests that the different cv folds use their own lambda sequence. Why was this change done in cv.glmnet code ? How does it add up ?
I looked at the web.stanford.edu/~hastie/glmnet/glmnet_alpha.html and it seems that we can compute a elastic model for any specified lambda within the range of lambda sequence used, once the model has been computed. So, while we use appropriate warm starts for each cross validation fold, but the original lambda sequence only acts as the lambda grid from which we choose the perfect lambda. Is my interpretation correct ?