The age-old question about whether a manual or automatic transmission is best for fuel efficiency has been around for over half a century As. petrol prices change and with global warming becoming an issue the argument gets more intense. The supporters of automatic cars will swear by their wonderful gas-efficiency while the manual drivers will argue the other way. To de sure driving automatic transmission is easier and more ergonomic. Fuel efficiency is related to multiple factors including the number of cylinders, the size of the engine and the weight of the car amongst other variables. This is a problem is ideally suited to multivariate regression analysis, if only there was a suitable database available to perform such an analysis.
The data was extracted from the 1974 Motor Trend US magazine (1). It comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). The data is historical however it is the only data set we have. The aim of the study is to perform the following assessments:
1- Is an automatic or manual transmission better for MPG?
2- Quantify the MPG difference between automatic and manual transmissions?
library(datasets)
head(mtcars)
## mpg cyl disp hp drat wt qsec vs am gear carb
## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
summary(mtcars)
## mpg cyl disp hp
## Min. :10.40 Min. :4.000 Min. : 71.1 Min. : 52.0
## 1st Qu.:15.43 1st Qu.:4.000 1st Qu.:120.8 1st Qu.: 96.5
## Median :19.20 Median :6.000 Median :196.3 Median :123.0
## Mean :20.09 Mean :6.188 Mean :230.7 Mean :146.7
## 3rd Qu.:22.80 3rd Qu.:8.000 3rd Qu.:326.0 3rd Qu.:180.0
## Max. :33.90 Max. :8.000 Max. :472.0 Max. :335.0
## drat wt qsec vs
## Min. :2.760 Min. :1.513 Min. :14.50 Min. :0.0000
## 1st Qu.:3.080 1st Qu.:2.581 1st Qu.:16.89 1st Qu.:0.0000
## Median :3.695 Median :3.325 Median :17.71 Median :0.0000
## Mean :3.597 Mean :3.217 Mean :17.85 Mean :0.4375
## 3rd Qu.:3.920 3rd Qu.:3.610 3rd Qu.:18.90 3rd Qu.:1.0000
## Max. :4.930 Max. :5.424 Max. :22.90 Max. :1.0000
## am gear carb
## Min. :0.0000 Min. :3.000 Min. :1.000
## 1st Qu.:0.0000 1st Qu.:3.000 1st Qu.:2.000
## Median :0.0000 Median :4.000 Median :2.000
## Mean :0.4062 Mean :3.688 Mean :2.812
## 3rd Qu.:1.0000 3rd Qu.:4.000 3rd Qu.:4.000
## Max. :1.0000 Max. :5.000 Max. :8.000
hist(mtcars$mpg, breaks = 16, col = "blue", xlab="Fuel efficiency (MpG)")
The first question is which one of these 2 methods of transmission is better for fuel efficiency. At face value this is a question of statistical inference i.e. does the difference in fuel efficiency between automatic and mauunal cars read statistical signficance and whether there is any association between fuel efficiency and transmission. The variable relating to the cars fuel efficiency is ‘mpg’.
The variable which classifies the cars’ transmission is ‘am’. Manual cars are recorderd as ‘1’ and automatic cars ‘0’.
MeanMPG_MAN<- mean(mtcars$mpg[mtcars$am=="0"]); StdDevMPH_Man<- sd(mtcars$mpg[mtcars$am=="0"])
MeanMPG_MAN; StdDevMPH_Man
## [1] 17.14737
## [1] 3.833966
MeanMPG_Aut<- mean(mtcars$mpg[mtcars$am=="1"]); StdDevMPH_Aut<- sd(mtcars$mpg[mtcars$am=="1"])
MeanMPG_Aut; StdDevMPH_Aut
## [1] 24.39231
## [1] 6.166504
t.test(mtcars$mpg~mtcars$am)$p.value
## [1] 0.001373638
Mean fuel consumption (efficiency) for Automatic cars is 17.147 mpg (std dev=3.833) and 24.39 mpg (std dev=6.166) for manual cars. This difference is statistically significant (P=0.00137).
mtcars$transmission<- factor(mtcars$am, labels=c("automatic", "manual"))
summary(lm(mpg~transmission, mtcars))
##
## Call:
## lm(formula = mpg ~ transmission, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.3923 -3.0923 -0.2974 3.2439 9.5077
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.147 1.125 15.247 1.13e-15 ***
## transmissionmanual 7.245 1.764 4.106 0.000285 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.902 on 30 degrees of freedom
## Multiple R-squared: 0.3598, Adjusted R-squared: 0.3385
## F-statistic: 16.86 on 1 and 30 DF, p-value: 0.000285
Clearly univariate regression analysis suggests that manual transmission is associated with significantly higher miles per gallon (mpg value) and lowerfuel consumption (better fuel efficiency).
The next question is whether after account for other variables automatic tansmission is still associated with higher fuel consumption (poorer fuel efficiency). For this we perform multivariate regression analysis. For this ‘mpg is selected as the dependent variable, ’am’ as the independent variable and ‘cyl’, ‘hp’ as well as ‘gear’ as covariates.
The following is a list of what these variables are recorded in a data frame with 32 observations on 11 (numeric) variables (1).
[, 1] mpg Miles/(US) gallon [, 2] cyl Number of cylinders [, 3] disp Displacement (cu.in.) [, 4] hp Gross horsepower [, 5] drat Rear axle ratio [, 6] wt Weight (1000 lbs) [, 7] qsec 1/4 mile time [, 8] vs Engine (0 = V-shaped, 1 = straight) [, 9] am Transmission (0 = automatic, 1 = manual) [,10] gear Number of forward gears
univar <- lm(mpg ~ am, data = mtcars)
multivar<- lm(mpg~am+cyl+hp+gear, mtcars)
summary(multivar)
##
## Call:
## lm(formula = mpg ~ am + cyl + hp + gear, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7608 -1.9415 -0.2465 1.5457 6.0684
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.13671 6.08447 4.953 3.46e-05 ***
## am 3.74434 1.74774 2.142 0.0413 *
## cyl -1.07827 0.73460 -1.468 0.1537
## hp -0.03797 0.01674 -2.269 0.0315 *
## gear 0.18297 1.31060 0.140 0.8900
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.857 on 27 degrees of freedom
## Multiple R-squared: 0.8043, Adjusted R-squared: 0.7753
## F-statistic: 27.74 on 4 and 27 DF, p-value: 3.245e-09
anova(univar, multivar)
## Analysis of Variance Table
##
## Model 1: mpg ~ am
## Model 2: mpg ~ am + cyl + hp + gear
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 30 720.90
## 2 27 220.39 3 500.5 20.439 4.06e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
After accounting for these variables the association between transmission and fuel consumption (mpg) is less significant (P=0.0413).
par(mfrow = c(2,2))
plot(multivar)
This question is also answered using linear regression analysis:
mtcars$transmission<- factor(mtcars$am, labels=c("automatic", "manual"))
summary(lm(mpg~transmission, mtcars))
##
## Call:
## lm(formula = mpg ~ transmission, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.3923 -3.0923 -0.2974 3.2439 9.5077
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.147 1.125 15.247 1.13e-15 ***
## transmissionmanual 7.245 1.764 4.106 0.000285 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.902 on 30 degrees of freedom
## Multiple R-squared: 0.3598, Adjusted R-squared: 0.3385
## F-statistic: 16.86 on 1 and 30 DF, p-value: 0.000285
Bearing in mind that the variable ‘am’ is a binary variable, the estimated coefficient (7.245) also represents the difference in mpg between automatic and manual transmissions.
Based on the analysis of the mtcars database which is a little dated now, manual cars have signficantly higher mpg values i.e are significantly more fuel efficient. Fuel efficiency is is a complex variable being dependent on multiple variables such as the number of forward gears, engine power in horse power and number of cylinders amongst other variables and once these variables are assigned as co-variates the association between transmission (am) and fuel efficiency ‘mpg’ becomes less significant.
Manual transmission cars have fuel efficiency which is higher by 7.245 mpg.