2024-11-14

Slide 1: Introduction to Simple Linear Regression

  • Simple Linear Regression is a method to model the relationship between two continuous variables.
  • It predicts the dependent variable \(Y\) based on the independent variable \(X\).
  • The linear regression equation is: \[ Y = \beta_0 + \beta_1 X + \epsilon \] where:
    • \(\beta_0\) is the intercept,
    • \(\beta_1\) is the slope,
    • \(\epsilon\) is the error term.

Slide 2: Purpose of Simple Linear Regression

  • Determine the strength and direction of the relationship between two variables.
  • Estimate the value of the dependent variable based on the independent variable.
  • Example applications:
    • Predicting a student’s score based on study hours.
    • Estimating a car’s fuel efficiency based on engine size.

Slide 3: Data and Plotting

  • This scatter plot shows the relationship between \(X\) and \(Y\).

Slide 4: The Linear Regression Model

  • Simple Linear Regression uses the formula:

    \[ \hat{Y} = \beta_0 + \beta_1 X \]

  • To estimate \(\beta_0\) (intercept) and \(\beta_1\) (slope), we minimize the sum of squared errors: \[ \text{SSE} = \sum_{i=1}^n (Y_i - \hat{Y}_i)^2 \]

Slide 5: Fit a linear regression model

Slide 6: 3D plot with plotly

Slide 7: Conclusion

Summary:

  • Linear regression predicts \(Y\) based on \(X\).
  • The regression line minimizes the sum of squared residuals.

Applications:

  • Predictive modeling in finance, healthcare, and more.

Slide 8: A sample of R code

# Scatter plot code
library(ggplot2)
ggplot(data, aes(x = x, y = y)) +
  geom_point(color = "blue") +
  labs(title = "Scatter Plot of X vs Y", x = "X", y = "Y")