October 2026

Question

Do heavier cars get worse gas mileage, and by how much?

  • Data: mtcars (32 cars, from Motor Trend 1974)
  • Response \(y\): miles per gallon (mpg)
  • Predictor \(x\): weight in 1000 lbs (wt)

We use simple linear regression to estimate how mpg changes as weight goes up.

The Model

Simple linear regression assumes

\[y_i = \beta_0 + \beta_1 x_i + \varepsilon_i, \quad \varepsilon_i \sim N(0, \sigma^2)\]

  • \(\beta_0\) is the intercept
  • \(\beta_1\) is the slope: the change in mpg for each extra 1000 lbs
  • \(\varepsilon_i\) is random error

Estimating the Coefficients

Least squares picks the line that minimizes the squared errors:

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

which gives

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

R Code

fit <- lm(mpg ~ wt, data = mtcars)
coef(fit)
## (Intercept)          wt 
##   37.285126   -5.344472
summary(fit)$r.squared
## [1] 0.7528328

The slope is negative, and \(R^2\) is about 0.75, so weight explains most of the variation in mpg.

Scatterplot with Fitted Line

The relationship is clearly negative: heavier cars get fewer miles per gallon.

Residuals

The residuals are mostly scattered around 0, with a slight curve, so a straight line fits reasonably well but not perfectly.

3D Plot: Weight, Horsepower, and MPG

Cars that are both heavy and powerful sit at the bottom, with the lowest mpg. Light, low-horsepower cars have the highest mpg.

Results

  • Fitted line: \(\widehat{mpg} = 37.29 -5.34 \times wt\)
  • Each extra 1000 lbs lowers mpg by about 5.34
  • \(R^2 = 0.75\): weight explains about 75% of the variation in mpg

Conclusion

  • Weight is a strong predictor of fuel efficiency.
  • The 3D plot shows horsepower also matters, so a model with more predictors could do better.
  • This data is observational and from 1974, so it shows association, not causation, and may not apply to modern cars.