2026-09-17

Key Terms

  • Simple Linear Regression is a method to understand the relationship between two variables.
  • The variable we want to infer or predict is called the dependent variable.
  • The variable we use for prediction is called the independent variable.

Linear Equation

The model is expressed with a linear equation:

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

  • y: The predicted dependent variable.
  • x: The independent predictor variable.
  • \(\beta_0\): The y-intercept (the value of y when x = 0).
  • \(\beta_1\): The slope (how much y changes for a one-unit increase in x).
  • \(\varepsilon\): The error term or residual.

Graph Example

  • The Gold line represents the Line of Best-Fit. This fits the data that minimizes the error residuals.
  • The Maroon points represent the spread of data.

Calculating “Error” \(\varepsilon\)

  • The dashed Black lines represent the distance from the line of best-fit or otherwise considered as the error residuals. \[\varepsilon_i = y_i - \hat{y}_i\]

Linear Regression Values from Previous Graph

Fitted Equation: \(\hat{y} = 1.3649 + 1.4918 x\)

  • Intercept (\(\beta_0\)): 1.3649
  • Slope (\(\beta_1\)): 1.4918
  • R-Squared (\(R^2\)): 0.8671

Interactive 3D Graph

set.seed(67)
myX <- rnorm(100, mean = 30, sd = 5)
myY <- rnorm(100)
myZ <- rnorm(100, mean = 15, sd = 2)

plot_ly(x = ~myX, y = ~myY, z = ~myZ,
        type = "scatter3d", mode = "markers",
        marker = list(color = "#8C1D40", size = 4),
        width = 700, height = 400) %>%
  hide_colorbar() %>%
  layout(scene = list(
    xaxis = list(title = "X"),
    yaxis = list(title = "Y"),
    zaxis = list(title = "Z")
  ))

3D Graph with Line of Best Fit