The question

Do heavier cars tend to travel fewer miles per gallon?

Fuel economy matters when comparing cars. A heavier vehicle may need more energy to move, but weight is only one part of the story.

I use correlation to describe the relationship and simple linear regression to estimate how MPG changes with weight.

Higher MPG means the car travels farther on one US gallon of fuel.

The data

R’s built-in mtcars dataset contains 32 cars from the 1973–1974 model years, reported in the 1974 Motor Trend magazine.

Variable Meaning
wt Vehicle weight, in thousands of pounds
mpg Miles per US gallon
hp Gross horsepower

These are observational data. The cars are a small historical sample, not a random sample of modern vehicles.

Source: R datasets documentation, “Motor Trend Car Road Tests.”

Heavier cars generally have lower MPG

The points slope downward. Cars near 2,000 lb generally achieve higher MPG than cars near 5,000 lb, although weight does not explain every difference.

Mathematics 1: measuring correlation

Pearson’s sample correlation measures the strength and direction of a linear relationship:

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

Here, \(x_i\) is weight and \(y_i\) is MPG for car \(i\).

For these cars, \(r = -0.868\).

The value is close to \(-1\), indicating a strong negative linear relationship in this sample. It does not show that weight alone causes the difference.

Mathematics 2: fitting a regression line

The model describes MPG as a linear function of weight plus an error term:

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

Least squares chooses the intercept and slope to minimize:

\[\sum_{i=1}^{n}(y_i-\hat{y}_i)^2, \qquad \hat{y}_i=b_0+b_1x_i\]

The fitted equation is:

\[\widehat{\mathrm{MPG}}=37.29-5.34\times\mathrm{weight\;(1,000\;lb)}\]

R code behind the analysis

library(ggplot2)
library(plotly)
cars <- datasets::mtcars
fit <- lm(mpg ~ wt, data = cars)
cor(cars$wt, cars$mpg)
summary(fit)
confint(fit, "wt")
ggplot(cars, aes(wt, mpg)) +
  geom_point(color = "#8C1D40") +
  geom_smooth(method = "lm", se = TRUE)

lm() estimates the line. cor() measures the relationship, and confint() gives a model-based interval for the slope.

The line captures much of the relationship

The slope is -5.34 MPG per 1,000 lb. The gold band is a 95% confidence interval for mean MPG under the model, not a prediction interval for an individual car.

What the fitted model means

  • An additional 1,000 lb is associated with about 5.34 lower MPG in this sample.
  • At 3,000 lb, the line predicts 21.3 MPG.
  • \(R^2 = 0.753\): weight accounts for about 75.3% of the observed variation in MPG around its sample mean.
  • The model-based 95% slope interval is [-6.49, -4.20] MPG per 1,000 lb.

The intercept predicts MPG at zero weight. That is outside the observed data and has no useful physical interpretation here.

Residuals show where the model misses

Some cars sit several MPG above or below the line. The pattern suggests possible curvature, so a straight line is a useful summary but may miss structure.

Interactive view: horsepower adds context

Drag to rotate, scroll to zoom, and hover to identify a car. Horsepower also varies with weight and MPG. This view gives context, but does not estimate an adjusted effect of weight.

Limits of the analysis

  • Association: Engine design and other features may help explain the relationship. This analysis does not isolate the causal effect of weight.
  • Scope: These 32 cars come from 1973–1974. The results should not be applied directly to modern cars or electric vehicles.
  • Model assumptions: Classical confidence intervals assume a linear mean relationship, independent errors, constant error variance, and normally distributed errors for exact small-sample inference.
  • Prediction: Predictions within the observed range are more defensible than extrapolation. A fitted mean does not describe every individual car.

What did we learn?

Heavier cars tend to have lower MPG in this dataset.

The correlation is -0.868, and the regression estimates about 5.34 fewer MPG per additional 1,000 lb.

The plots support that conclusion, while the residuals show that weight alone leaves differences unexplained.

A useful next step would compare a curved relationship or include horsepower, then evaluate predictions on new data.

Sources