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.
From an exploratory analysis we can see that fuel effieciency varies inversely with weight and horsepower. Regression lines have been added in each case, which appear to fit well.
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):
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.
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)
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)
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")
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)