2025-10-19

What is Simple Linear Regression?

Simple Linear Regression is a linear regression model used to estimate the relationship between two variables by using a straight line.

It is most commonly used in a relationship between a independent and dependent variable, to show how the dependent changes as the independent variable changes.

What are Independent and Dependent Variables?

The Dependent Variable

  • The effect
  • The value depends on changes in the independent variable
  • Mathematically depicted as the output and is commonly associated with the variable Y

The Independent Variable

  • The cause
  • The value is independent of other variables
  • Mathematically depicted as the input and is commonly associated with the variable X

The Equation for Simple Linear Regression

\[ \text{y} = \alpha + \beta \text{x} + \varepsilon \]

Explanation:

  • The x variable is the independent value
  • The y variable is the dependent variable
  • The \(\alpha\) variable is a constant value that represents the y-intercept
  • The \(\beta\) variable is a value that represents the slope of the line
  • The \(\varepsilon\) variable is the random deviation

Simple Linear Regression In Use

Using the mtcars data set, we will look at the relationship between Miles per Gallon (mpg) and Weight (wt) of the cars.

The variables will consist of:

  • Weight (wt) as the Independent, x variable
  • Miles per Gallon (mpg) as the Dependent, y variable

So:

\[ \text{mpg} = \alpha + \beta \text{(wt)} + \varepsilon \]

Car Data with Simple Linear Regression Line

ggplot(mtcars, aes(x = wt, y = mpg)) + geom_smooth(method = "lm") +
    geom_point() + labs(x = "Weight of Car (wt)", y = "Miles per Gallon (mpg)",
    title = "Simple Linear Regression Model of Weight to MPG of Car")

Another Example: MPG compared to Gross Horsepower

We can also look at the relationship between miles per gallon to gross horsepower

Simple Linear Regression in 3D Space

We can put the points on a 3D coordinate grid and create a linear regression plane