Executive Summary

A manual-transmission car yields about 1.81 miles/(US) gallon more (which is better) than an automatic-transmission one.

Introduction

This analysis aimed to address two questions:

  1. Is an automatic or manual transmission better for MPG?
  2. Quantify the MPG difference between automatic and manual transmissions.

The analysis was done in RStudio with the “mtcars” dataset.

Exploratory Analysis

Figure 1 (see Appendices) shows that automatic transmission tended to have lower MPG than manual one.

First Regression Analysis and Diagnosis of Residuals

To answer the question, we first fitted MPG with transmission in linear model.

fit1<-lm(mpg ~ am,data = mtcars)

By diagnosis of rediduals (see Figure 2-5), there is no remarkable pattern shown. But, this doesn’t rule out the fact that some important variables might be omitted in the first model. Hence, we attempted fitting other models and determined the best one.

The Best Model

To determine the best model, we added one more variable at a time and compared between the old and new models by anova. If the new model shows insignificantly different at 5% level of significance, we will exclude the newly added variable out of the model.

fit2<-lm(mpg ~ am + factor(cyl),data = mtcars)
fit3<-lm(mpg ~ am + factor(cyl) + disp,data = mtcars)
fit4<-lm(mpg ~ am + factor(cyl) + disp + hp,data = mtcars)
fit5<-lm(mpg ~ am + factor(cyl) + disp + hp + drat,data = mtcars)
fit6<-lm(mpg ~ am + factor(cyl) + disp + hp + drat + wt,data = mtcars)
fit7<-lm(mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec,data = mtcars)
fit8<-lm(mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs,data = mtcars)
fit9<-lm(mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs + gear,data = mtcars)
fit10<-lm(mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs + gear + carb,data = mtcars)

(See anova results in Appendices). Hence, best fit is,

bestfit<-lm(mpg ~ am + factor(cyl) + disp + hp + wt,data = mtcars)

Interpretation

bestfit$coefficients
##  (Intercept)           am factor(cyl)6 factor(cyl)8         disp 
## 33.864276061  1.806099494 -3.136066556 -2.717781289  0.004087893 
##           hp           wt 
## -0.032480178 -2.738694608

Since the coefficient of transmission (am) is 1.8060995, it means that, given other variables constant, being manual transmission (am = 1) increases MPG about 1.81; in other words, manual transmission is better for MPG.

Appendices

Figure 1:

Figure 2-5:

Anova:

anova(fit1,fit2,fit3,fit4,fit5,fit6,fit7,fit8,fit9,fit10)
## Analysis of Variance Table
## 
## Model  1: mpg ~ am
## Model  2: mpg ~ am + factor(cyl)
## Model  3: mpg ~ am + factor(cyl) + disp
## Model  4: mpg ~ am + factor(cyl) + disp + hp
## Model  5: mpg ~ am + factor(cyl) + disp + hp + drat
## Model  6: mpg ~ am + factor(cyl) + disp + hp + drat + wt
## Model  7: mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec
## Model  8: mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs
## Model  9: mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs + 
##     gear
## Model 10: mpg ~ am + factor(cyl) + disp + hp + drat + wt + qsec + vs + 
##     gear + carb
##    Res.Df    RSS Df Sum of Sq       F    Pr(>F)    
## 1      30 720.90                                   
## 2      28 264.50  2    456.40 34.2326 3.488e-07 ***
## 3      27 230.46  1     34.04  5.1057   0.03516 *  
## 4      26 183.04  1     47.42  7.1136   0.01480 *  
## 5      25 182.38  1      0.66  0.0987   0.75664    
## 6      24 150.10  1     32.28  4.8425   0.03968 *  
## 7      23 141.21  1      8.89  1.3343   0.26166    
## 8      22 139.02  1      2.18  0.3275   0.57354    
## 9      21 135.27  1      3.75  0.5629   0.46183    
## 10     20 133.32  1      1.95  0.2921   0.59485    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1