R code
Please find some R code used to fit and plot some models. You can find most data sets on Moodle. Please download data and try some of the R code as you read through these notes.
Search strategy
In the previous lecture, we considered two search strategies.
- All subset where we search all possible models.
- Stepwise selection where we begin with an initial model and systematically add or remove variables one at a time.
All subset regression was considered previously and so today we will conserder option (2)
Model selection for Motor Trend Car Road Tests data
The data was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). A full description of the data can be found with the R command
These data contain 32 observations on 11 (numeric) variables.
mpg
Miles/(US) galloncyl
Number of cylindersdisp
Displacement (cu.in.)hp
Gross horsepowerdrat
Rear axle ratiowt
Weight (1000 lbs)qsec
1/4 mile timevs
Engine (0 = V-shaped, 1 = straight)am
Transmission (0 = automatic, 1 = manual)gear
Number of forward gearscarb
Number of carburetors
Recall for the last lecture where we wanted to model mpg
using the remaining variables as explanatory variables.