2026-03-08

What is Linear Regression

Simple linear regression models the relationship (or lack of) between two variables.

\[ x = \text{predictor variable}, \quad y = \text{response variable} \]

The goal is to estimate a linear relationship between them:

\[ y \approx \beta_0 + \beta_1 x \]

where that line represents the best linear fit to the data we have.

Regression Equation

The goal equation for simple linear regression is:

\[ y = \beta_0 + \beta_1 x + \epsilon \]

Where:

  • \(y\) = dependent (response) variable
  • \(x\) = independent (predictor) variable
  • \(\beta_0\) = y-intercept
  • \(\beta_1\) = slope
  • \(\epsilon\) = random error estimate

The regression line represents the best estimate of \(y\) for a given value of \(x\)

Plotly 3D Graph about Cars

Even though simple linear regression typically is in 2d with 1 independent variable, looking at a 3d graph from 2d perspective can reveal patterns about the data

GGplot1

GGplot2

Code for the 3D Plot

p <- plot_ly(
  data = mtcars,
  x = ~wt,
  y = ~hp,
  z = ~mpg,
  type = "scatter3d",
  mode = "markers",
  marker = list(size = 4)
)
layout(p, 
  title = "3D graph for car data",
  scene = list(
    xaxis = list(title = "Weight"),
    yaxis = list(title = "Horsepower"),
    zaxis = list(title = "Miles per Gallon")
  )
)

Thanks for viewing!

this presentation was made for a class to learn how to use R statistical tools