The question

How does vehicle weight relate to fuel economy?

  • Fuel economy is miles per US gallon (mpg). Higher values mean less fuel per mile.
  • Weight is measured in thousands of pounds.
  • We use simple linear regression to describe the association and its uncertainty.

A comparison of 2,000 lb and 3,000 lb cars corresponds to a one-unit change in weight.

The data: 32 historical cars

  • R’s built-in mtcars data contain 32 car models from 1973–74.
  • Each row represents one model. We analyze wt and mpg.
  • Weight ranges from 1.51 to 5.42 thousand lb.
  • Fuel economy ranges from 10.4 to 33.9 mpg.

These observational data illustrate a method. They do not represent a random sample of today’s cars.

Source: R datasets::mtcars documentation, based on the 1974 Motor Trend US magazine.

Heavier cars tend to have lower mpg

The fitted line slopes downward. The shaded band shows a 95% confidence interval for the mean response under the model.

Mathematics: the regression model

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

  • \(Y_i\): fuel economy of car \(i\), in mpg.
  • \(x_i\): weight of car \(i\), in thousands of pounds.
  • \(\beta_1\): expected mpg difference per additional 1,000 lb.

Least squares chooses the line that minimizes squared residuals:

\[ (\hat\beta_0,\hat\beta_1)=\arg\min_{b_0,b_1} \sum_{i=1}^{32}\left(y_i-b_0-b_1x_i\right)^2. \]

Mathematics: estimating the slope

\[ \hat\beta_1= \frac{\sum_i(x_i-\bar x)(y_i-\bar y)}{\sum_i(x_i-\bar x)^2}, \qquad \hat\beta_0=\bar y-\hat\beta_1\bar x \]

Our fitted equation is:

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

An additional 1,000 lb is associated with about 5.34 fewer mpg in this dataset.

The intercept corresponds to a zero-weight car, outside the data, so it has no useful physical interpretation here.

R code: fitting and visualizing the model

library(ggplot2)
library(plotly)
d <- datasets::mtcars
fit <- lm(mpg ~ wt, data = d)
coef(fit)
confint(fit)
summary(fit)$r.squared

ggplot(d, aes(wt, mpg)) +
  geom_point(color = "#8C1D40") +
  geom_smooth(method = "lm", formula = y ~ x)

lm() estimates the line. confint() quantifies coefficient uncertainty. The chart lets us compare the line with the observations.

Mathematics: uncertainty in the slope

A model-based 95% confidence interval for the slope is:

\[ \hat\beta_1 \pm t_{0.975,\,n-2}\,\mathrm{SE}(\hat\beta_1) = [-6.49,\ -4.2]. \]

  • Plausible slopes under the model correspond to 4.2 to 6.49 fewer mpg per additional 1,000 lb.
  • The 95% refers to long-run coverage of intervals made by this procedure under its assumptions.
  • The usual interval relies on a linear mean relationship and independent, normally distributed errors with constant variance.

The sample design limits population generalization even when the fitted relationship is strong.

The line leaves some structure unexplained

The curved residual trend suggests the straight line misses some pattern. A residual plot alone cannot verify all model assumptions.

Interactive exploration

Hover to identify models. Drag to zoom and double-click to reset. Compare cars with similar weight but different mpg.

What the model explains

  • \(R^2 = 0.753\): weight accounts for about 75% of the observed variation in mpg around its sample mean.
  • At 3,000 lb, the fitted mean is 21.3 mpg.
  • Individual cars vary around that mean. A mean estimate does not guarantee the mpg of a particular car.

This describes the fitted sample. It does not establish predictive accuracy on new data.

Conclusion

Heavier cars in this sample tend to have lower fuel economy.

The estimated difference is about 5.3 fewer mpg per additional 1,000 lb.

Weight alone leaves meaningful differences unexplained. Engine characteristics and other design choices may matter, and the residual pattern suggests a nonlinear model could be worth checking.

These observational data support an association. They do not isolate a causal effect of adding weight, and they should not directly guide comparisons of modern cars.

Sources and reproducibility

  • Data: R Core Team, mtcars documentation. Original source: Henderson and Velleman (1981), “Building multiple regression models interactively,” Biometrics, 37, 391–411.
  • Model functions: R stats::lm, confint, and predict.
  • Graphics: ggplot2 and plotly for R.
  • All numerical results and charts are computed from datasets::mtcars when this Rmd is knitted.

No external data files are required. The accompanying README explains how to render and prepare the Canvas submission.