I want to use Lasso or ridge regression for a model with more than 50,000 variables. I want do so using software package in R. How can I estimate the shrinkage parameter ($\lambda$)?
Edits:
Here is the point I got up to:
set.seed (123)
Y <- runif (1000)
Xv <- sample(c(1,0), size= 1000*1000, replace = T)
X <- matrix(Xv, nrow = 1000, ncol = 1000)
mydf <- data.frame(Y, X)
require(MASS)
lm.ridge(Y ~ ., mydf)
plot(lm.ridge(Y ~ ., mydf,
lambda = seq(0,0.1,0.001)))
My question is: How do I know which $\lambda$ is best for my model?