Executive Summary

This report explores the relationship between transmission type (automatic or manual) and miles per gallon (MPG) in cars. The goal is to answer whether an automatic or manual transmission is better for MPG and quantify the MPG difference between the two.

Data Exploration

Let’s start by exploring the data.

summary(cars_data)
##       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       Transmission      
##  Min.   :0.0000   Min.   :3.000   Min.   :1.000   Length:32         
##  1st Qu.:0.0000   1st Qu.:3.000   1st Qu.:2.000   Class :character  
##  Median :0.0000   Median :4.000   Median :2.000   Mode  :character  
##  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

Exploratory Data Analysis

# Boxplot to visualize MPG by transmission type
ggplot(cars_data, aes(x = Transmission, y = mpg)) +
  geom_boxplot() +
  labs(title = "MPG by Transmission Type", x = "Transmission Type", y = "MPG")

The boxplot illustrates a noticeable difference in MPG between automatic and manual transmissions in the mtcars dataset. Manual transmissions tend to have higher median MPG, suggesting a potential relationship.

Regression Analysis

# Fit a linear regression model
model <- lm(mpg ~ Transmission, data = cars_data)

# Summarize the model
summary(model)
## 
## Call:
## lm(formula = mpg ~ Transmission, data = cars_data)
## 
## 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

A linear regression model was fitted to explore the relationship between transmission type and MPG in the mtcars dataset. The results indicate a significant difference in MPG between automatic and manual transmissions (p < 0.05), supporting the idea that transmission type affects fuel efficiency.

# Extract coefficients
coefficients <- coef(model)
mpg_difference <- coefficients["TransmissionManual"]

# Interpretation
cat("The average MPG difference between manual and automatic transmissions is approximately", round(mpg_difference, 2), "MPG.")
## The average MPG difference between manual and automatic transmissions is approximately 7.24 MPG.

Diagnostics

# Residual plot
plot(model, which = 1)

Conclusion

In conclusion, our analysis suggests that there is a significant difference in MPG between automatic and manual transmissions. The average MPG for manual transmissions is estimated to be higher than automatic. transmissions by approximately X MPG.