Understanding the relation of car transmission in the fuel consumption (MPG) using regression - Course Project Leonardo Alves - September 18, 2016
Executive Summary Looking at a data set of a collection of cars, we are interested in exploring the relationship between a set of variables and miles per gallon (MPG) (outcome). We are particularly interested in the following two questions: • •
Is an automatic or manual transmission better for MPG? Quantify the MPG difference between automatic and manual transmissions.
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). We'll use regression models to obtain the answers for the initial questions.
Exploratory data analysis Doing some exploratory data analysys to better understand the dataset mtcars. Looking for the linear relationship of mpg with others variables (appendix 0).
Model selection The purpose of this model was answer the questions about consumption (MPG) and possible differences between automatic and manual transmission regarding consumption (see Executive summary). The variable selection procedure was made using Stepwise regression (AIC criteria). Usually you don’t want to blindly follow a model selection procedure, but when the models are naturally nested (this case for example), this is a reasonable approach (page 100, reference book). Only the two best models were displayed bellow. The code used to stepwise regression: library(MASS) fit F) ## wt 1 847.73 847.73 140.2143 2.038e-12 *** ## qsec 1 82.86 82.86 13.7048 0.0009286 *** ## as.factor(am) 1 26.18 26.18 4.3298 0.0467155 * ## Residuals 28 169.29 6.05 ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1# # (Intercept) wt qsec as.factor(am)1 # # 9.617781 -3.916504 1.225886 2.935837 The manual transmission is better for MPG. The P-value was significant for this group comparison (0.0467155 *) considering 95% confidence level. Thus we expect a 2.935837 MPG increase in mean comparing manual to automatic transmission (Manual - Automatic). We can conclude that manual is better than automatic transmission regarding MPG (better fuel consumption). •
Quantify the MPG difference between automatic and manual transmissions. ## 2.5 % 97.5 % ## (Intercept) -4.63829946 23.873860 ## wt -5.37333423 -2.459673 ## qsec 0.63457320 1.817199 ## am 0.04573031 5.825944
The difference between Manual and Automatic transmission (manual - automatic) was 2.9358 MPG. The 95% confidence interval for this estimate is: [0.04573031; 5.825944]. This report was made using RMD (knitr to word).