[R] glmnet() vs. lars()
patrick.breheny at uky.edu
Wed Mar 21 15:26:03 CET 2012
On 03/21/2012 06:30 AM, Vito Muggeo (UniPa) wrote:
> It appears that glmnet(), when "selecting" the covariates entering the
> model, skips from K covariates, say, to K+2 or K+3. Thus 2 or 3
> variables are "added" at the same time and it is not possible to obtain
> a ranking of the covariates according to their importance in the model.
> On the other hand lars() "adds" the covariates one at a time.
> My question is: is it possible to obtain a similar output of lars (in
> terms of order of the variables entering the model) using glmnet()?
glmnet() is based on an iterative coordinate descent algorithm applied
to a grid of lambda values; LARS is a more elegant algorithm and
computes exact solutions. You can get your glmnet solutions to have
higher resolution (more "exact") by using a finer grid. In your example:
 0 2 4 4 ...
The default is a grid of 100 lambda values. If we use 300 values, the
resolution is finer and we can see the variables enter one at a time:
 0 1 1 2 3 3 4 ...
However, it is impossible to know in advance how fine the grid must be
in order to ensure that only one variable enters the model between any
two consecutive lambda values.
Department of Biostatistics
Department of Statistics
University of Kentucky
More information about the R-help