# CV.glmnet results [duplicate]

I was working through the lab on ridge regression and LASSO in ISLR and I came across a strange behavior in the cv.glmnet function. When I followed the lab as written I got the following

set.seed(1)
train <- sample(1:nrow(x), nrow(x)/2)
test <- (-train)
y.test <- y[test]
set.seed(1)
cv.out <- cv.glmnet(x[train,], y[train], lambda=grid, alpha=0)
plot(cv.out)
bestlam <- cv.out\$lambda.min
bestlam
[1] 231.013


For my own benefit I tried it using a different seed (8675309) and got back a different result. Any combination of setting the seeds resulted in different answers. I am assuming this has to do with how the 10-folds are changed with the different seeds, however the different lambda.min can vary so much I am concerned the package might not be stable. Am I missing something?

• Nice choice of different seed :D – Nick Stauner Jan 15 '14 at 4:18
• Do the models indicated by the respective lambda.min for the different runs/seeds match - have similar included variables or coefs? Have you tried the lambda.1se option, which is the simplest model within 1 standard error of the best (lambda.min), which may be more stable, esp if the MSE is relatively flat around the "best" model. – Gavin Simpson Jan 15 '14 at 5:17
• I think the point is the same as [here][1] [1]: stats.stackexchange.com/questions/97777/… – Alice Jun 12 '14 at 16:07
• This question appears to be off-topic because it is specific to the GLMNET package in R. Those are generally off topic now, so I am voting to close my own question. – Fraijo Jul 30 '14 at 19:03
• @Fraijo, I'd disagree--I think it's just on the topical side of the line, in that it's a question about the stuff implemented by GLMNET and not the syntax, etc. – Matt Krause Jul 30 '14 at 20:52