In the documentation of the function cv.glmnet()
, it is given that:
lambda.1se :
largest value of lambda such that error is within 1 standard error of the minimum.
Which means that lambda.1se
gives the lambda
, which gives an error (cvm
) which is one standard error away from the minimum error.
So, while trying to check this fact:
There is a data set Boston
in the library MASS
. I performed a cross validation, using the lasso:
x = model.matrix(crim~.-1,data=Boston)#-1 for removing the intercept column
y = Boston$crim
cv.lasso = cv.glmnet(x,y,type.measure = "mse",alpha=1)
And the value of cv.lasso$lambda.min
comes out to be:
> cv.lasso$lambda.min
[1] 0.05630926
And, the value of cv.lasso$lambda.1se
is:
> cv.lasso$lambda.1se
[1] 3.375651
Now, look at this:
> std(cv.lasso$cvm)
[1] 0.7177808
Where std
is a function, that returns the standard error of the values inserted in it.1
And the minimum value of cvm
can be found as:
> cv.lasso$cvm[cv.lasso$lambda==cv.lasso$lambda.min]
[1] 42.95009
So, we add the standard error to the value of cvm
and we get:
> 42.95009+0.7177808
[1] 43.66787
Even though there is no lambda
value corresponding to this cvm
value, we can have an idea on the basis of existing data:
Which means lambda.1se
should be between 0.4784899 and 0.4359821. But that's absolutely not the case. So, there's a gut feeling that says I'm making a blunder here. Can you help me point at that?
1:Definition of std
:
std<-function(x)
sd(x)/sqrt(length(x))