MPG Efficiency Analysis

This is a brief analysis of MPG efficiency for various cars. The data set can be found at GeeksForGeeks. For this brief analysis I will focus on MPG, Number of Cylinders, Displacement and Year. This set contains 398 observations, a summary is below.

      mpg          cylinders      displacement        year      
 Min.   : 9.00   Min.   :3.000   Min.   : 68.0   Min.   :70.00  
 1st Qu.:17.50   1st Qu.:4.000   1st Qu.:104.2   1st Qu.:73.00  
 Median :23.00   Median :4.000   Median :148.5   Median :76.00  
 Mean   :23.51   Mean   :5.455   Mean   :193.4   Mean   :76.01  
 3rd Qu.:29.00   3rd Qu.:8.000   3rd Qu.:262.0   3rd Qu.:79.00  
 Max.   :46.60   Max.   :8.000   Max.   :455.0   Max.   :82.00  

Overview

MPG vs Displacement

The linear regression is:

\[\text{mpg} = 35.17 -0.06 \times \text{displacement}\]

Linear Regression

Some Formulas

The linear regression equations are mpg (m), displacement (d):

4 cylinder: \(m = 43.79 + (-0.13) \cdot d\)

6 cylinder: \(m = 30.4 + (-0.05) \cdot d\)

8 cylinder: \(m = 22.73 + (-0.02) \cdot d\)


We can see that displacement has a bigger effect for 4 cylinder engines.

Code

Sample code used to calculate linear regression for 4 cylinder engines.

autoMPG4 <- autoMPG[autoMPG$cylinders == 4,]
linearMod4 <- lm(mpg ~ displacement, data = autoMPG4)
intercept4 <- coef(linearMod4)[1]
    slope4 <- coef(linearMod4)[2]

Histogram

MPG Efficiency decreases for higher cylinder count.