Solved – How to interpret cross validation plot from glmnet

glmnetr

After I run cv.glmnet for alpha=0 I want to plot it. I understand most of the plot but I do not understand what do the two dashed gray lines surrounding the red MSE dots(top and bottom) mean in the plot. Does the distance between the two lines mean anything? Here is the plot:enter image description here

Best Answer

As you can read in the vignette, the upper and lower bar around the $MSE$ results for each $\lambda$ denote the $MSE$ plus/minus its standard error. Thus, you can reconstract the upper and lower boundaries, by calculating

cvdata$cvm + c(cvdata$cvsd,-cvdata$cvsd)

EDIT: I somehow misread your question, but I'll not delete the old explanation regarding the pointed vertical lines, in case it's still relevant to you:

One line is simply the $\lambda$ corresponding to the minimum MSE of the cross validation (your left dotted line) . When adding one standard error to the minimum MSE value, you get a more regularized model, i.e. one that performs favorable for predicting purposes. The $\lambda$ value belonging to it is denoted by the right dotted line.

The values can be accessed by

cvdata$lambda.min; cvdata$lambda.1se