Ridge regression and LASSO

Gota Morota

February 24, 2020

Data

library(glmnet)
library(BGLR)  # use the wheat dataset
data(wheat)
data(wheat)
y <- wheat.Y[, 2]  # use the second phenotype
W <- wheat.X
dim(W)
[1]  599 1279

Ridge vs. LASSO (fixed marker effects)

# lambda = 0.01
a_ridge1 <- glmnet(W, y, alpha = 0, lambda = 0.01)  # use alpha = 0 for Ridge
a_lasso1 <- glmnet(W, y, alpha = 1, lambda = 0.01)  # use alpha = 1 for LASSO
plot(a_ridge1$beta, a_lasso1$beta)