0

I'm searching for a best subset selection algorithm for ridge regression in R. There is a wide range of algoritms for an ordinary least squares fit. There also exists a function like stepAIC for the ordinary least squares fit.

Does anybody have experience with ridge regression in R?

Richard Hardy
  • 54,375
  • 10
  • 95
  • 219
Markus
  • 63
  • 3
  • 2
    Asking for `R` code / functions / packages is off topic here. However, you should be aware that selection algorithms like best subset are very bad things to do (to understand why, it may help to read my answer here: [Algorithms for automatic model selection](http://stats.stackexchange.com/a/20856/7290)). You would be better off mixing ridge with a LASSO penalty (ie, the [elastic net](https://cran.r-project.org/web/packages/glmnet/index.html)). – gung - Reinstate Monica Feb 21 '16 at 15:47

1 Answers1

2

Ridge regression is not a variety of subset selection. Ridge regression keeps all the variables in the model (thus there is no selection) but shrinks their coefficients towards zero. Using ridge regression makes sense if all the variables are somewhat important but estimating their effects via OLS yields too large a model variance. If you want not only shrinkage but also variable selection, you may look at LASSO or elastic net instead.

Ridge regression, LASSO and elastic net are implemented in R package "glmnet". In the function glmnet specify the argument alpha=0 to get a ridge regression, alpha=1 for LASSO, and alpha in between zero and one for elastic net regression.

Richard Hardy
  • 54,375
  • 10
  • 95
  • 219