Overview

1.- Goal

You work for Motor Trend, a magazine about the automobile industry. Looking at a data set of a collection of cars, they are interested in exploring the relationship between a set of variables and miles per gallon (MPG) (outcome). They are particularly interested in the following two questions:

2.- Excecutive Summary

In this report we investigate the relationships between automatic or manual transmission on the miles per gallon (MPG) consumption of automobiles. For the exploration of these questions we will use the mtcars data set https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/mtcars.html.

Analysis

3.- Data

data(mtcars)
str(mtcars)
## 'data.frame':    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : num  0 0 1 1 0 1 0 1 1 1 ...
##  $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
##  $ gear: num  4 4 4 3 3 3 3 4 4 4 ...
##  $ carb: num  4 4 1 1 2 1 4 2 2 4 ...

The mtcars data set contains 11 variables. The first variable mpg is our output variable and the variable am contains the transmission type as binary numbers. Following the reported documentation in the webpage of the mtcars data set we first pre-process the am variable in a readable and suitable way for the subsequent analysis.

mtcars$am[mtcars$am==0]<-"Automatic"
mtcars$am[mtcars$am==1]<-"Manual"
mtcars$am<-as.factor(mtcars$am)
str(mtcars$am)
##  Factor w/ 2 levels "Automatic","Manual": 2 2 2 1 1 1 1 1 1 1 ...

4.- Is an automatic or manual transmission better for MPG?

A simple exploration shows that the mean of the MPG Manual transmission is higher than the corresponding MPG consumption for the Automatic transmission:

aggregate(mpg~am, data = mtcars, mean)
##          am      mpg
## 1 Automatic 17.14737
## 2    Manual 24.39231

This result can be confirmed by an statistical student’s t test.

automaticMPG <- mtcars$mpg[mtcars$am=="Automatic"]
manualMPG    <- mtcars$mpg[mtcars$am=="Manual"]
t.test(automaticMPG, manualMPG)
## 
##  Welch Two Sample t-test
## 
## data:  automaticMPG and manualMPG
## t = -3.7671, df = 18.332, p-value = 0.001374
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -11.280194  -3.209684
## sample estimates:
## mean of x mean of y 
##  17.14737  24.39231

Now we can confirm (with 95% of confidence) that there is indeed a difference between the means of these conditions. The MPG consumption of Manual cars are higher than those of Automatic cars.