Fig2.5: Reproduce Figure 2.5

View source: R/lasso-path.R

Fig2.5R Documentation

Reproduce Figure 2.5

Description

Reproduces Figure 2.5 from the book; if you specify any options, your results may look different.

Usage

Fig2.5(cv = TRUE, mar = rep(5, 4))

Arguments

cv

Carry out cross-validation? Default: true

mar

Margins, passed to par()

Examples

Fig2.5()

# default glmnet plot
attachData(pollution)
fit <- glmnet(std(X), y)   # Standardize design matrix
plot(fit, label=TRUE)

# Nonzero coefficients at CV-selected lambda
cvfit <- cv.glmnet(X, y, nfolds=length(y))
colnames(X)[unlist(predict(cvfit, type="nonzero"))]


pbreheny/hdrm documentation built on Jan. 17, 2024, 8:53 p.m.