Professional Documents
Culture Documents
TWP Streams Replication 11gr1 130056
TWP Streams Replication 11gr1 130056
Upon first examination, there does appear to be a relationship between transmission type and miles per
gallon wherein cars with manual transmission get better mileage (Fig 1).
Figure 1
Relationship between Transmission Type and MPG
35
30
25
MPG
20
15
10
Automatic Manual
Transmission Type
However, following an exploratory analysis (Supplementary Fig 1), it appears that this apparent relationship
may be explained by other variables. Specifically, if you examine the number of cylinders and the weight
of the car (which are known to impact mileage) in conjunction with transmission type, a more complete
picture becomes evident (Fig 2). When looking between groups with the same number of cylinders, the
only difference between automatic (am:0) and manual (am:1) are in the 4 cylinder group. But even these
differences may be due to the lower weight in manual cars.
Figure 2
Exploring Confounding Variables
am: 0 am: 1
35
30
25
MPG
20
15
10
4 6 8 4 6 8
Cylinders
wt
2 3 4 5
To quantify the relationship between transmission type and MPG, I built three nested linear models and
calculated the coefficient of transmission type for each model. The same trend can be seen in the coefficients
1
as in the graphs. As more explanatary variables are added, the coefficient for transmission type decreases to
almost zero.
I then used Analysis of Variance to determine if the models are distinct from one another. From the P-values,
it is evident that the additional variables do indeed change the model fit.
Furthermore, in plotting the residuals against the fitted values for each model, it is apparent that the range
of the residuals decreases in each model. Thus each of the additional of each explanatory variable leads to a
better fitting model.
Model 1 Model 2 Model 3
5 10
6
Residuals
Residuals
Residuals
4
2
0
0
−6 −2
−4
−10
18 22 16 20 24 10 20
Executive Summary
While there is a difference in miles per gallon seen between vehicles with automatic and manual transmission,
it seems to be due to the increased number of manual cars with fewer cylinders and lower weight. As such,
after accounting for these explanatory variables manual cars only have a 0.17 increase in mpg as compared to
automatic cars.
2
Appendix
Supplementary Figure 1
4 6 8 50 300 2 4 0.0 0.8 3.0 4.5
mpg
10
4 8
cyl
disp
100
hp
50
drat
3.0
wt
2
qsec
16
vs
0.0
am
1.0
gear
3.0
1 8
carb
10 30 100 3.0 5.0 16 22 1.0 1.8 1 5