Jan 28, 2018

Week3 Assignment

Brief Introduction


  • Data used: Boston data from MASS
  • Package: plotly for plotting data; leaps for regsubsets function.

Indirect Method

Function: regsubsets
- regsubsets finds the best model for each number of predictors
- method is either forwards, backwards, or exhaustive (best subset selection) - here I tested the best subset selection method

Indirect Method

  • summary of regsubset model. The outmat shows which predictors it chose for each number
b <- summary(a)
noquote(b$outmat)
##           zn indus chas nox rm age dis rad tax ptratio black lstat medv
## 1  ( 1 )                               *                               
## 2  ( 1 )                               *                     *         
## 3  ( 1 )                               *               *     *         
## 4  ( 1 )  *                        *   *                           *   
## 5  ( 1 )  *                        *   *               *           *   
## 6  ( 1 )  *             *          *   *               *           *   
## 7  ( 1 )  *             *          *   *       *       *           *   
## 8  ( 1 )  *             *          *   *       *       *     *     *   
## 9  ( 1 )  *  *          *          *   *       *       *     *     *   
## 10  ( 1 ) *  *          *   *      *   *       *       *     *     *   
## 11  ( 1 ) *  *          *   *      *   *   *   *       *     *     *   
## 12  ( 1 ) *  *     *    *   *      *   *   *   *       *     *     *   
## 13  ( 1 ) *  *     *    *   *  *   *   *   *   *       *     *     *

Indirect Method

  • Each row is a model, the rows at the top were the best
  • Indicates that the predictor was included in that model
  • Based on Cp, the lower the better

Indirect Method