Our question

How much does vehicle weight help predict fuel economy?

Imagine comparing a 2,000-pound car with a 3,000-pound car.

Fuel economy is measured in miles per US gallon (mpg). Higher mpg means a car travels farther on one gallon of fuel.

We will use scatterplots and simple linear regression to investigate the relationship.

Our data

The built-in R dataset mtcars contains 32 cars from the 1973–1974 model years.

  • mpg: fuel economy in miles per US gallon.
  • wt: weight in 1,000 pounds.
  • Each row represents one car model.

For example, wt = 3 means 3,000 pounds.

These historical road tests are observational data, not a randomized experiment or a representative sample of modern cars.

Source: R documentation for mtcars.

A closer look at six cars

Model Weight (pounds) Fuel economy (mpg)
Mazda RX4 2620 21.0
Mazda RX4 Wag 2875 21.0
Datsun 710 2320 22.8
Hornet 4 Drive 3215 21.4
Hornet Sportabout 3440 18.7
Valiant 3460 18.1

These are the first six rows of the dataset. Our regression uses all 32 cars.

Similar weights do not always correspond to similar fuel economy.

Heavier cars tend to have lower mpg

The downward pattern suggests a negative association.

The spread of points shows that weight alone does not explain every difference.

Mathematics: the regression model

Simple linear regression describes mean mpg with a straight line:

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

  • \(Y_i\): mpg of car \(i\).
  • \(x_i\): weight in 1,000 pounds.
  • \(\beta_1\): change in mean mpg per additional 1,000 pounds.
  • \(\varepsilon_i\): deviation from the population line.

The intercept \(\beta_0\) refers to zero weight. That value is outside our data and has no useful physical interpretation here.

Mathematics: finding the best line

Least squares finds the line that minimizes squared residuals:

\[ \min_{b_0,b_1} \sum_{i=1}^{n} [y_i-(b_0+b_1x_i)]^2 \]

A residual is:

\[ e_i = y_i-\hat{y}_i \]

It measures observed mpg minus predicted mpg.

Squaring prevents positive and negative residuals from canceling and gives larger errors more influence.

The analysis in R

library(ggplot2)
library(plotly)

cars <- mtcars
fit <- lm(mpg ~ wt, data = cars)

coef(fit)
confint(fit)
summary(fit)$r.squared

Our fitted equation is:

\[ \widehat{\mathrm{mpg}} = 37.29 - 5.34\,\mathrm{wt} \]

An additional 1,000 pounds is associated with about 5.34 fewer mpg, on average in this model.

The fitted regression line

The fitted model accounts for about 75.3% of the sample variation in mpg.

The shaded band shows a 95% confidence interval for mean mpg, not an individual car’s mpg.

Regression results at a glance

Statistic Result
Number of cars 32
Slope (mpg per additional 1,000 pounds) -5.34
95% confidence interval for slope -6.49 to -4.20
R-squared 0.753

The negative slope describes lower average mpg as weight increases.

A high R-squared does not establish causation or guarantee accurate predictions for every car.

Mathematics: uncertainty in the slope

A 95% confidence interval for the slope is:

\[ \hat{\beta}_1 \pm t_{0.975,n-2}\,\mathrm{SE}(\hat{\beta}_1) \]

With 32 cars, there are 30 residual degrees of freedom:

\[ -5.344 \pm 2.042(0.559) = [-6.49,-4.20] \]

Under the model assumptions, repeated samples and this method would produce intervals containing the population slope about 95% of the time.

The interval is entirely negative, supporting a negative association under those assumptions.

Predictions for a 3,000-pound car

The fitted value is 21.25 mpg.

Target 95% interval (mpg)
Mean mpg at 3,000 pounds 20.12 to 22.38
One additional car at 3,000 pounds 14.93 to 27.57

An individual car varies around the mean, so its prediction interval is wider.

These intervals assume a new car comes from the same modeled population.

Interactive exploration with Plotly

Hover to identify cars. Drag to zoom, then double-click to reset.

Compare cars near the same weight: their mpg can still differ.

Checking the model with residuals

The curved smooth suggests possible nonlinearity.

Standard inference assumes a linear mean, independent errors, constant error variance, and approximately normal errors. This plot cannot establish all assumptions.

What did we learn?

Weight helps predict fuel economy in these 32 historical cars.

  • An additional 1,000 pounds is associated with about 5.34 fewer mpg.
  • The model accounts for about 75.3% of sample variation in mpg.
  • Individual predictions remain uncertain.

Engine characteristics and other differences may confound the relationship. These data do not establish that reducing weight causes this exact mpg improvement.

A next step would include horsepower and evaluate predictions on separate data.

Sources