Notes on The Elements of Statistical Learning


The Elements of Statistical Learning was written by Trevor Hastie, Robert Tibshirani, and Jerome Friedman. This page stores my notes as I work through the chapters of this book. I am using R 2.2.1 and R GUI 1.14 for Mac OS X.

Obtaining the ElemStatLearn Package

The data sets, functions, and examples from the book have been packaged by Kjetil Halvorsen and are available as the ElemStatLearn package. Here’s how to install the ElemStatLearn package using R for Mac OS X:

  1. In the R GUI, click on the Packages & Data menu and select Package Installer.
  2. In the R Package Installer window, click on the popup menu at the upper left of the window and select CRAN (binaries), then click on the Get List button.
  3. R may prompt you at this point to choose a CRAN mirror site.
  4. In the package list, select ElemStatLearn, then click on the Install Selected button at the lower right. R downloads and installs the ElemStatLearn package on your system. When the download is complete, the value in the Installed Version column is updated.
  5. Close the R Package Installer window.

Loading the ElemStatLearn Package

Here is the command for loading the ElemStatLearn package in an R session so you can use it:

library( package = ElemStatLearn )


The ElemStatLearn package contains the following functions:

Data sets

The ElemStatLearn package contains the following data sets:

The examples for some of the data sets are extensive. For example:

##  Load the packages required by example( prostate ).

library( package = ElemStatLearn )
library( package = leaps )
library( package = mda )
library( package = lasso2 )
library( package = lars )

##  Get information about the prostate data set.


##  Run the example.

get( getOption( "device" ) )()
par( ask = TRUE )
example( prostate )

The example fails during the call to l1ce() from the lasso2 package:

prostt> library(lasso2)

prostt> prostate.lasso <- l1ce(lpsa ~ ., data = train, trace = TRUE,
    sweep.out = ~1, bound = seq(0, 1, by = 0.1))
Error in l1ce(lpsa ~ ., data = train, trace = TRUE, sweep.out = ~1,
bound = seq(0,  :
	Oops, something went wrong in .C("mult_lasso",..): -1

The rest of the example runs correctly when it is pasted in.