2026-06-07

Introduction

Simple linear regression is one of the most common statistical tools.

It is used to:

  • Describe relationships between variables
  • Make predictions
  • Quantify trends
  • Evaluate strength of association

Example question:

Can vehicle weight predict fuel efficiency?

The Data

We will use the built-in R dataset mtcars.

The dataset contains information on 32 automobiles and includes measurements such as fuel efficiency, weight, horsepower, and number of cylinders.

Variables:

  • mpg = Miles per gallon
  • wt = Vehicle weight (1000 lbs)
  • hp = Horsepower
  • cyl = Number of cylinders

Our goal:

Predict mpg from wt

Regression Model

A simple linear regression model is:

\[ Y = \beta_0 + \beta_1X + \varepsilon \]

where

  • \(Y\) = response variable
  • \(X\) = predictor variable
  • \(\beta_0\) = intercept
  • \(\beta_1\) = slope
  • \(\varepsilon\) = random error

For this example:

\[ mpg = \beta_0 + \beta_1(wt)+\varepsilon \]

Least Squares Estimation

Regression chooses coefficients that minimize:

\[ SSE=\sum_{i=1}^{n}(y_i-\hat y_i)^2 \]

where

\[ \hat y_i=\beta_0+\beta_1x_i \]

The method is called:

Ordinary Least Squares (OLS)

The fitted line minimizes the total squared residual error.

Scatterplot with Regression Line

Residual Plot

Interactive Plotly Visualization

Example R Code

library(ggplot2)

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

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

Results

Key findings from the regression model:

  • Estimated slope = -5.34
  • R² = 0.753
  • p-value < 0.001
  • Vehicle weight is a significant predictor of fuel efficiency
  • Heavier vehicles tend to have lower MPG

Interpretation:

For every additional 1000 pounds of vehicle weight, fuel efficiency decreases by approximately 5.3 MPG.

Conclusion

Simple linear regression is a powerful statistical tool that:

  • Quantifies relationships between variables
  • Helps make predictions
  • Provides interpretable results
  • Is widely used in business, science, engineering, and data analytics

In this example, vehicle weight was a strong predictor of fuel efficiency.

Thank you!