0
$\begingroup$

I'm trying to fit a Lasso Regression Model to a dataset but I have been stucked in some issues. I understand that I have to fit the best model using the proper lambda. But every time I run the cv.glmnet function it gives different values for lambda.1se and lambda.min and also different coefficients, i.e, different models with differents MSE and R-Squared values. Which one should I use? Does it make sense to replicate this function 1000 times and use the average lambda or the average coefficients value?

$\endgroup$
  • $\begingroup$ This seems more like a theoretical question than one about glmnet, so I am voting to keep it open. $\endgroup$ – Peter Flom Sep 29 '17 at 12:17
  • $\begingroup$ There is some randomization in the cross-validation process. You can run "set.seed(some number)" before the cv.glmnet call to avoid it. $\endgroup$ – Xiao Chen Oct 9 '18 at 7:59
0
$\begingroup$

Unless your training set is small, the best way is to remove a validation set (at least 100 data points, or 10% of the training set if this is larger), and run the model with different parameters. The difference between the fit on the training data and the validation set is the overfitting. Choose parameters that minimise overfitting, not parameters that maximise the fit to the training data.

$\endgroup$
  • $\begingroup$ My training data is really small. Actually the entire dataset is small (about 40 observations). I'm trying to fit a LASSO regression because it's better for small datasets, but every time I do the cross-validation it returns a different lambda. What if I choose the lambda value that minimises the model MSE? $\endgroup$ – Pedro H. Araujo Oct 3 '17 at 15:54
  • $\begingroup$ WIth a dataset that small, the best you can do is LOOCV (leave one out cross validation). $\endgroup$ – Hugh Morris Oct 22 '17 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.