October 18, 2026

1. The Question

Does a heavier car tend to have worse fuel economy?

  • We measure fuel economy in miles per gallon (mpg).
  • Vehicle weight is measured in thousands of pounds (wt).
  • Our goal is to describe the relationship, quantify its strength, and make an informed prediction.
A relationship in observed data does not, by itself, prove that weight causes a change in mpg.

2. Meet the Data

The built-in R dataset mtcars contains measurements for 32 automobile models from a 1974 automotive magazine dataset.

  • wt: weight in units of 1,000 pounds
  • mpg: fuel economy in miles per gallon
  • cyl: number of cylinders; useful context when comparing vehicles

In this sample, weights range from 1.51 to 5.42 thousand pounds.

Source: R built-in mtcars dataset; documentation: ?mtcars.

3. First Look: A Scatterplot

Interpretation: Heavier vehicles generally have lower mpg, suggesting a negative association.

4. Mathematics: Correlation

The Pearson correlation coefficient measures the direction and strength 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}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}} \]

For these 32 vehicles, \(r = -0.868\).

  • Negative sign: higher weight tends to go with lower mpg.
  • Magnitude close to 1: the linear association is strong in this sample.

5. Mathematics: The Regression Model

We model average mpg as a straight-line function of weight:

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

The fitted line is:

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

  • Intercept: a mathematical anchor, not a realistic prediction for a zero-weight car.
  • Slope: each additional 1,000 lb is associated with about 5.34 fewer mpg on average in the fitted model.

6. The Fitted Line (ggplot2)

Interpretation: The downward line shows the fitted average trend. The shaded region is a 95% confidence band for mean mpg, not an individual-car prediction interval.

7. How Much Variation Does Weight Explain?

\[ R^2 = 1 - \frac{\sum_i (y_i-\hat y_i)^2} {\sum_i (y_i-\bar y)^2} \]

Our regression has \(R^2 = 0.753\), or about 75.3%.

In this dataset, vehicle weight accounts for about 75.3% of the variation in mpg under this simple linear regression model. It does not mean weight causes exactly that percentage of fuel economy.

The remaining variation may involve engine design, aerodynamics, gearing, and other factors not included here.

8. Interactive Exploration (Plotly)

Hover over a point to identify the car and its weight, mpg, and cylinder count. Drag to zoom; double-click to reset.

9. R Code Behind the Analysis

Here is the essential code used to calculate the relationship and draw the regression line.

# mtcars is included with R
library(ggplot2)
data(mtcars)

fit <- lm(mpg ~ wt, data = mtcars)
cor(mtcars$wt, mtcars$mpg)
summary(fit)$r.squared

ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  geom_smooth(method = "lm", se = TRUE)

R functions: lm() fits the linear model; cor() measures linear association; ggplot() and geom_smooth() visualize the data and fitted trend.

10. What Would the Model Predict?

Using the fitted line, consider two hypothetical vehicle weights within the observed range:

Weight Predicted fuel economy
2,500 lb (wt = 2.5) 23.9 mpg
3,500 lb (wt = 3.5) 18.6 mpg

The heavier example is predicted to achieve about 5.3 fewer mpg.

These are model predictions for average mpg, not guaranteed outcomes for particular cars.

11. Interpretation and Limitations

What supports our conclusion?

  • Scatterplot and regression line both show a downward pattern.
  • The correlation is -0.868, indicating a strong negative linear relationship.
  • The model’s \(R^2\) is 0.753.

What should we be careful about?

  • Only 32 older automobile models are included.
  • Engine type, cylinders, and design differences could confound the relationship.
  • The fitted line should not be extrapolated far beyond the observed weights.
  • Association does not establish causation.

12. The Takeaway

Question: Does vehicle weight help explain fuel economy?

Answer: Yes, in mtcars, heavier vehicles tend to have lower mpg. Simple linear regression makes this pattern interpretable and quantifiable.

What we learned:

  1. Statistics turns an apparent pattern into a measurable relationship.
  2. Mathematics defines correlation, a regression line, and explained variation.
  3. R, ggplot2, and Plotly communicate the evidence through static and interactive visuals.
Final message: Vehicle weight is a useful predictor of mpg in this sample, but predicting modern vehicle performance would require newer, richer data.

Data: built-in R mtcars dataset. Methods and visualizations created with base R, ggplot2, and Plotly.