2025-10-26

Equation For Linear Regression Line

  • Linear Regression: \(\beta_0 + \beta_1 x + \varepsilon\)

  • \(\beta_0\): y-intercept of the linear regression line

  • \(\beta_1\): slope of the linear regression line

  • \(\varepsilon\): the error of the linear regression

How Linear Regression Line is Calculated

-Least Squares Solution: \(\sum_{i=1}^{n}(y_i - \hat{y}_i)^2\)

-\(y_i\): observed value

-\(\hat{y}_i\): predicted value

-Goal: to minimize this sum

Model Assesment

  • Goodness of fit: how well a statistical model fits an observed data set
  • Standard error of estimate: the average how far the actual data point is from predicted point for all points
  • Residual plots: a graph used to to see how far the actual data point is from the predicuted point

Model Assesment: Residual Plot

Model Assesment: Residual Plot Code

#Importing Data
data(mtcars)

#Fitting data w/ linear regression model
model <- lm(mpg ~ hp, data = mtcars)

#Creating residual plot 
ggplot(model, aes(x = .fitted, y = .resid)) +
  geom_point() +
  geom_hline(yintercept = 0) +
  labs(title = 'Fuel Efficency vs HP Residuals',
       x = "HP",
       y = "Miles Per Gallon")

3D Linear Regression

Asumptions Made

  • Linearity between x and y
  • Independence of errors
  • Homoscedasticity
  • Normality of Errors

Applications

  • Used in structural engineering to predict predict stress on materials

  • Used in healthcare to calculate dosages

  • Used in electrical engineering predict signal distortion

  • Images by Freepik