2026-10-18

The Question

Does a bigger engine means more fuel consumption?

Does fuel economy vary across cars with four, six, and eight cylinders, and how does it change as engine size increases?

The Data

  • Dataset: mtcars, built into R (32 cars, 1974 Motor Trend road test)
  • mpg: fuel efficiency (miles per gallon)
  • disp: engine size (displacement, cubic inches)
  • wt: weight (thousands of pounds)
mpg disp wt
Mazda RX4 21.0 160 2.620
Mazda RX4 Wag 21.0 160 2.875
Datsun 710 22.8 108 2.320

First Look

At first glance, it is evident that fuel efficiency decreases with engine size. About 34 mpg is the maximum for 4-cylinder vehicles, 21 mpg for 6-cylinder vehicles, and less than 20 mpg for 8-cylinder vehicles.

The Model

Simple linear regression describes how one variable changes with another:

\[y_i = \beta_0 + \beta_1 x_i + \varepsilon_i\]

  • \(y_i\): fuel efficiency (mpg) of car \(i\)
  • \(x_i\): engine size (disp) of car \(i\)
  • \(\beta_0\): the intercept, which anchors the line but is not feasible for an actual automobile, is the expected mpg when engine size is 0.
  • \(\beta_1\): we anticipate that the slope, or how much mpg increases for every cubic inch of engine size, will be negative.
  • \(\varepsilon_i\): The random mistake, the portion of an automobile’s mpg that the line fails to explain, and other elements like weight or design.

Least Squares

We select the line that minimizes the squared errors:

\[\min_{\beta_0,\,\beta_1} \sum_{i=1}^{n} \left(y_i - \beta_0 - \beta_1 x_i\right)^2\]

The solution is:

\[\hat{\beta}_1 = \frac{\sum_{i=1}^{n}(x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^{n}(x_i - \bar{x})^2}, \qquad \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x}\]

To put it another way, we measure each car’s vertical distance, square that distance, and total the results. The line that reduces this sum as much as feasible is the optimal one.

R Code

model <- lm(mpg ~ disp, data = mtcars)
coef(model)
## (Intercept)        disp 
## 29.59985476 -0.04121512
summary(model)$r.squared
## [1] 0.7183433

The Fitted Line

  • Slope ≈ -0.041: every additional cubic inch reduces mpg by roughly 0.04, translating to about 4 mpg for every 100 cubic inches.

  • R2 = 0.72 : engine size accounts for approximately 72% of the differences in mpg.

  • A few small-engine vehicles are positioned significantly above the line, indicating that the relationship is not entirely linear.

Interactive 3D View

Larger vehicles generally come with more powerful engines, and in a 3D view, 4-cylinder cars are positioned higher (offering better fuel efficiency) compared to the lower stance of 8-cylinder cars.

What Did We Learn?

  • Our question: Indeed, a larger engine consumes more fuel. For every additional cubic inch, fuel efficiency decreases by approximately 0.04 mpg (around 4 mpg for every 100 cubic inches).

  • Strength: The size of the engine accounts for approximately 72% of the variation in mpg (\(R^2 = 0.72\)), making it a reliable predictor.

  • Cylinders: Cars with 4-cylinder engines are more fuel-efficient and have smaller engines, whereas 8-cylinder cars feature larger engines but are less efficient in terms of miles per gallon.

  • Limits: The pattern is not entirely linear, and the analysis included just 32 vehicles from 1974. This indicates a correlation, but does not confirm that engine size by itself reduces mpg.