October 25, 2026

The Question

Do cars with larger engines tend to use more fuel?

  • Engine size can be measured using displacement.
  • Fuel efficiency is measured in miles per gallon (MPG).
  • We will examine the relationship using statistics and graphs.

The Data

We will use the built-in R dataset mtcars.

  • It includes 32 cars.
  • disp is engine displacement in cubic inches.
  • mpg is miles driven per gallon of fuel.
  • Higher MPG means better fuel efficiency.
##                                 car disp  mpg
## Mazda RX4                 Mazda RX4  160 21.0
## Mazda RX4 Wag         Mazda RX4 Wag  160 21.0
## Datsun 710               Datsun 710  108 22.8
## Hornet 4 Drive       Hornet 4 Drive  258 21.4
## Hornet Sportabout Hornet Sportabout  360 18.7

Statistical Idea: Correlation

Correlation measures how strongly two numerical variables move together.

  • Values near 1 show a strong positive relationship.
  • Values near -1 show a strong negative relationship.
  • Values near 0 show little linear relationship.

Here we expect a negative correlation: larger engines often have lower MPG.

Mathematics: Pearson Correlation

Pearson’s correlation coefficient is

\[ r = \frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})} {\sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}} \]

For our data, \(x\) is engine displacement and \(y\) is MPG.

The calculated correlation is -0.848.

Mathematics: Linear Regression

A simple linear regression line is written as

\[ \hat{y} = b_0 + b_1x \]

Here, \(\hat{y}\) is predicted MPG and \(x\) is displacement.

Our estimated equation is

\[ \widehat{MPG} = 29.6 + (-0.0412) \times displacement \]

The slope is negative, meaning predicted MPG falls as displacement increases.

R Code Used

This is the main R code used for the analysis.

cars <- mtcars
cor(cars$disp, cars$mpg)
fit <- lm(mpg ~ disp, data = cars)
summary(fit)

The built-in dataset makes this analysis easy to reproduce.

Visualization 1: Scatterplot

The downward trend suggests larger engines generally have lower MPG.

Visualization 2: MPG by Cylinders

Cars with more cylinders tend to have lower fuel efficiency in this dataset.

Interactive Visualization: Explore the Cars

Hover over any point to see which car it represents.

What Do the Numbers Mean?

  • The correlation between displacement and MPG is -0.848.
  • This shows a strong negative linear relationship in these 32 cars.
  • The regression slope is -0.0412 MPG per cubic inch.
  • Correlation does not prove that changing engine size alone causes the difference in MPG.

Conclusion

  • The data show that larger engine displacement is associated with lower MPG.
  • The scatterplot and correlation tell a consistent story.
  • The boxplot gives another view of fuel efficiency across cylinder counts.
  • Other factors, such as weight and vehicle design, can also influence MPG.

Overall, engine size is a useful predictor of fuel efficiency in the mtcars dataset.