Solved – R Ridge Regression: Choosing best lambda

rridge regression

I am doing ridge regression with Mass package and stuck with the problem trying to find the best lambda.
I know that it should look somehow like thi

lm.ridge(y ~x1 + x2+ x3...data = data, lambda=seq(0,1,.1))
help <- lm.ridge(y ~x1 + x2+ x3...data = data, lambda=seq(0,1,.1))
plot(help)
select(help)

select(help) gives me the following output:

modified HKB estimator is 13.50453 
modified L-W estimator is 85.33649 
smallest value of GCV  at 1 

But what is my best lambda the? The smallest value for GCV?
Also I don't understand what values I should pick for

lambda=seq(0,1,.1)

I hope someone can help me!

Best Answer

(Changing a comment to an answer.) Yes, you want the lambda that minimizes GCV. MASS's lm.ridge doesn't choose a default lambda sequence for you. Look at this question which talks about good default choices for lambda. Also, I'd suggest using cv.glmnet with alpha = 0 (meaning ridge penalty) from glmnet package which will do this cross validation with some good lambdas for you. Use glmnetUtils package in addition if you like a formula interface like lm.ridge. See ?cv.glmnet after installing glmnet (and glmnetUtils, if you want).