0

I am using the r package glmnet to do the lasso for Correlated Variable Selection. I need to find the lambdas associated with the minimum mean squared value following answer from Variablity in cv.glmnet results. I used the code below:

my_data<-as.matrxi(my_data)
x<-my_data[,-1]
y<-my_data[,1]
cvob10<-cv.glmnet(x,y)
plot(cvob10) 

The result is on the left of the figure below. Minimum MSE corresponds to very large lambdas which could not help me to select predictors in the next step.

For comparison, I tried the swiss data in r. Using the same code.

swiss<-as.matrxi(swiss)
x<-swiss[,-1]
y<-swiss[,1]
cvob8<-cv.glmnet(x,y)
plot(cvob8)

I got a different result(on the right of the figure below). Small MSEs corresponds to small lambdas. enter image description here

I have repeated many times of the codes above. My questions are:
1. Is the relationship between MSE and log(lambda) important?
2. What information can I take from the figure above?
3. If my min.lambda associated with very large MSE, can I still trust it and use it select my predictors?

ay__ya
  • 23
  • 1
  • 8
  • Your MSEs are insanely large that is the first indication that you are doing something wrong, perhaps you forgot to scale your variables. Secondly, the results suggest only one variable should be left in the model. I will first check the scaling of all variables in ```X```. – Chamberlain Mbah Mar 19 '18 at 13:36
  • Thank you for your comments. My lambdas are very high as well. – ay__ya Mar 19 '18 at 13:53
  • The size of $\lambda$ should not be your concern. It is required that you scale your variables before penalizing to get correct results. Second is the size of $Y$ comparable to the MSE? If not then check you data closely. There is a huge outlier somewhere. – Chamberlain Mbah Mar 19 '18 at 13:56
  • My Xs are land use information variables scales are varying from 0 to 1000000. My Y is air pollution data which is around 10000. I think I need to reduce the number of my predictors to 20-26. MSE of my data reduce significantly when just 26 predictors left. – ay__ya Mar 19 '18 at 14:04
  • Again I repeat you have to scale your ```X```. All variables in ```X``` must be scaled. You are penalizing the sizes of your coefficient if one ```x``` is already too large, you are already favoring that ```x```. Scaling takes off this issue. – Chamberlain Mbah Mar 19 '18 at 14:08
  • I think you are right. I will try to rescale my X. – ay__ya Mar 19 '18 at 14:11

0 Answers0