I am using cross validation in glmnet package and have some difficulties in understanding foldid option. Why do I still get random results if I use foldid?
load("QuickStartExample.RData")
foldid=sample(1:10,size=length(y),replace=TRUE)
for(i in 1:10){
print(cv.glmnet(x,y,foldid)$lambda.min)
}
# The outputs
[1] 0.1035043
[1] 0.09430923
[1] 0.09430923
[1] 0.09430923
[1] 0.02336112
[1] 0.1035043
[1] 0.08593106
[1] 0.03389298
[1] 0.01767183
[1] 0.09430923