Exercise for glmnet

LASSO, Ridge regression, Elastic Net and rpart

Install packages.

install.packages("ISLR") ## ISLR - data from Introduction to Statistical Learning with R
install.packages("glmnetUtils")
install.packages("plotmo")
install.packages("rpart.plot")

ISLR - Labs

In the ISLR book they have Lab sessions that are walk-throughs of how to use R for the discussed methodologies.

  • Ridge regression: Section 6.6.1
  • LASSO regression: Section 6.6.2

Salary for baseball hitters

In the dataset Hitters there is data from Major League Baseball Data from the 1986 and 1987 seasons:

data(Hitters, package = "ISLR")

Use Salary as response variable and fit models using

  • LASSO
  • Ridge regression
  • rpart (to be introduced in later session - i.e. return to this later)

Identify the best model e.g. by RMSE

ISLR Exercises (Section 6.8, pp 262 - 263)

  • Exercise 8: Parts (a), (b), and (e)
  • Exercise 9: (a) - (e)