ic.glmnet: Estimate a GLM with lasso, elasticnet or ridge regularization...

Description Usage Arguments Details Value References See Also Examples

Description

Uses the glmnet (for family = "gaussian") function from the glmnet package to estimate models through all the regularization path and selects the best model using some information criterion. The glmnet package chooses the best model only by cross validation (cv.glmnet). Choosing with information criterion is faster and more adequate for some aplications, especially time-series.

Usage

1
ic.glmnet(x, y, crit = c("bic", "aic", "aicc", "hqc"), ...)

Arguments

x

Matrix of independent variables. Each row is an observation and each column is a variable.

y

Response variable equivalent to the function.

crit

Information criterion.

...

Aditional arguments to be passed to glmnet.

Details

Selecting the model using information criterion is faster than using cross validation and it has some theoretical advantages in some cases. For example, Zou, Hastie, Tibshirani (2007) show that one can consistently estimate the degrees of freedom of the LASSO using the BIC. Moreover, Information Criterions are becoming very popular, especially on time-series applications where cross-validation may impose further complications.

The information criterions implmemented are the Bayesian Information Criterion (bic), the Akaike Information Criterion (aic) and its sample size correction (aicc) and the Hannah and Quinn Criterion (hqc).

Value

An object with S3 class ic.glmnet.

coefficients

Coefficients from the selected model.

ic

All information criterions.

lambda

Lambda from the selected model.

nvar

Number of variables on the selected model including the intercept.

glmnet

glmnet object.

residuals

Residuals from the selected model.

fitted.values

Fitted values from the selected model.

ic.range

Chosen information criterion calculated through all the regularization path.

call

The matched call.

References

Garcia, Medeiros and Vasconcelos (2017).

Jerome Friedman, Trevor Hastie, Robert Tibshirani (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1-22. URL http://www.jstatsoft.org/v33/i01/.

Zou, Hui, Trevor Hastie, and Robert Tibshirani. "On the “degrees of freedom” of the lasso." The Annals of Statistics 35.5 (2007): 2173-2192.

See Also

glmnet, cv.glmnet, predict, plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## == This example uses the Brazilian inflation data from
#Garcia, Medeiros and Vasconcelos (2017) == ##
data("BRinf")

## == Data preparation == ##
## == The model is yt = a + Xt-1'b + ut == ##
aux = embed(BRinf,2)
y=aux[,1]
x=aux[,-c(1:ncol(BRinf))]

## == Ridge == ##
ridge=ic.glmnet(x,y,crit = "bic",alpha=0)
coef(ridge)


## == LASSO == ##
lasso=ic.glmnet(x,y,crit = "bic")
coef(lasso)
fitted(lasso)
residuals(lasso)
lasso$ic

## == Adaptive LASSO == ##
tau=1
# Lasso as the first step model, intercept must be removed
# to calculate the penalty factor.
first.step.coef=coef(lasso)[-1]
penalty.factor=abs(first.step.coef+1/sqrt(nrow(x)))^(-tau)
adalasso=ic.glmnet(x,y,crit="bic",penalty.factor=penalty.factor)
coef(adalasso)
adalasso$ic

gabrielrvsc/HDeconometrics documentation built on April 28, 2020, 7:12 a.m.