Summary

This report seeks to answer whether cars with manual or automatic transmission are the most fuel efficient. Analysis is based on the application of simple linear regression models to the 1974 Motor Trend Car Road Tests (mtcars) dataset.

It is shown that automatic transmission gives better fuel efficiency than manual for an average car with 19.24 MPG vs 17.07 MPG.

Complete r code for this analysis is shown in the appendix, rather than inline, to aid readability.


Analysis

Effect of transmission on fuel efficiency

Using the seperate models for automatic and manual we can determine how fast fuel efficiency declines as weight and HP increase.

decrease in MPG per 1000lbs decrease in MPG per 100 HP
Automatic -3.79 -5.91
Manual -9.08 -5.87

Both transmission types vary simmilarly with horse power, but fuel efficiency of manual vehicles decreases much faster than automatics as weight increases.

We can also predict the fuel efficiency for an average weight car (3217.25 lbs):

  • with automatic transmission would be 19.24 MPG within a 95% confidence interval 13.69 to 24.78
  • with manual transmission would be 17.07 MPG within a 95% confidence interval 10.54 to 23.6


Evaluation of model

Residuals

By plotting the residuals we can see that the linear models chosen are a good fit as there are no obvious patterns in the residual spread.

Appendix - Code

Fitting models

data(mtcars)
autocars <- mtcars[mtcars$am==0,]
manucars <- mtcars[mtcars$am==1,]

wt_auto.lm <- lm(mpg~wt, data=autocars)
hp_auto.lm <- lm(mpg~hp, data=autocars)
wt_manu.lm <- lm(mpg~wt, data=manucars)
hp_manu.lm <- lm(mpg~hp, data=manucars)

par(mfrow=c(1,2),oma = c(0, 0, 2, 0), mar=c(5,5,1,1)+0.1)
plot(autocars$mpg~autocars$wt,xlab="Weight (lbs/1000)",ylab="Efficiency (mpg)",col="blue",bg="lightblue",pch=21)
abline(wt_auto.lm,col="darkblue")
plot(autocars$mpg~autocars$hp,xlab="Horse Power (HP)",ylab="Efficiency (mpg)",col="blue",bg="lightblue",pch=21)
abline(hp_auto.lm,col="darkblue")
mtext("Fuel Efficiency For Automatic by weight and horse power", outer = TRUE, cex = 1.5)

par(mfrow=c(1,2),oma = c(0, 0, 2, 0), mar=c(5,5,1,1)+0.1)
plot(manucars$mpg~manucars$wt,xlab="Weight (lbs/1000)",ylab="Efficiency (mpg)",col="blue",bg="lightblue",pch=21)
abline(wt_manu.lm,col="darkblue")
plot(manucars$mpg~manucars$hp,xlab="Horse Power (HP)",ylab="Efficiency (mpg)",col="blue",bg="lightblue",pch=21)
abline(hp_manu.lm,col="darkblue")
mtext("Fuel Efficiency For Manual by weight and horse power", outer = TRUE, cex = 1.5)

Extracting coefficients of models

co1 <- round(summary(wt_auto.lm)$coefficients[2, 1],2)
co2 <- round(summary(hp_auto.lm)$coefficients[2, 1]*100,2)
co3 <- round(summary(wt_manu.lm)$coefficients[2, 1],2)
co4 <- round(summary(hp_manu.lm)$coefficients[2, 1]*100,2)

Prediction of MPG for an average weight car

avwt <- mean(mtcars$wt)
newwt = data.frame(wt=avwt)
pred_auto <- predict(wt_auto.lm, newwt, interval="predict")
pred_manu <- predict(wt_manu.lm, newwt, interval="predict") 

Plotting residuals

par(mfrow=c(1,2),oma = c(0, 0, 2, 0), mar=c(5,5,1,1)+0.1)
plot(autocars$wt,resid(wt_auto.lm),xlab="Weight (lbs/1000)",ylab="Residual variance",col="red",bg="pink",pch=21)
plot(manucars$wt,resid(wt_manu.lm),xlab="Weight (lbs/1000)",ylab="Residual variance",col="red",bg="pink",pch=21)