Slide 1: Introduction

  • Simple linear regression is a statistical method used to model the relationship between two continuous variables, often referred to as the independent variable (X) and the dependent variable (Y). The fundamental idea is to understand and quantify how changes in the independent variable are associated with changes in the dependent variable.
  • The importance of simple linear regression lies in its ability to provide insights into the nature and strength of the relationship between two variables. It allows us to make predictions and understand how changes in one variable might affect the other. Additionally, simple linear regression is a foundational concept in statistics and serves as a building block for more complex regression analyses.

Slide 2: Linear Regression Model (Latex)

  • The simple linear regression model is modeled as such where Y is the dependant variable, X is the independant variable, beta_0 is the y-intercept, beta_1 is the slope, and epsilon is the error: \[[ Y = \beta_0 + \beta_1X + \epsilon ]\]

Slide 3: Assumptions of Simple Linear Regression

  • First and foremost is the assumption of linearity, implying that the relationship between the independent and dependent variables is linear. Additionally, independence of residuals is essential, meaning that the observed values should not be influenced by each other. Homoscedasticity ensures that the spread of errors remains consistent. Normality of residuals is another assumption, though it becomes more critical for smaller sample sizes. Autocorrelation, where residuals exhibit patterns over time, should be avoided. Finally, the additivity assumption ensures that changes in the independent variable have a constant effect on the dependent variable. Careful consideration and validation of these assumptions are crucial for accurate interpretation and meaningful insights from linear regression analyses.

Slide 4: Example Data

  • We will demonstrate uses of linear regression using generated data for X and Y
X <- rnorm(100)
Y <- 2 * X + rnorm(100)
data <- data.frame(X = X, Y = 2 * X + rnorm(100))
  • We will model the data in a scatter plot (next slide)
# Create a scatter plot
ggplot(data, aes(x = X, y = Y)) +
  geom_point() +
  labs(title = "Scatter Plot of X and Y",
       x = "X",
       y = "Y")

Slide 5: Scatter Plot (ggplot)

Slide 6: Simple Linear Regression (ggplot)

  • Now we will model a simple linear regression on the data we have created using the following structure:
# Fit a linear regression model
model <- lm(Y ~ X, data = data)
# Create a scatter plot with regression line
ggplot(data, aes(x = X, y = Y)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "blue") +
  labs(title = "Simple Linear Regression",
       x = "X",
       y = "Y")

Slide 7: Simple Linear Regression (ggplot)

## `geom_smooth()` using formula = 'y ~ x'

Slide 8: Residuals (Latex)

  • The residuals in a linear regression model represent the differences between the observed values and the values predicted by the regression equation. Here, epsilon is the vector of residuals, Y is the vector of observed values, and Y_hat is the vector of predicted values: \[[ e_i = Y_i - \hat{Y}_i ]\]

Slide 9: Residuals Plot (plotly)

  • Finally, we will model the residual 3d plot of the regression model. Thank you!