- Simple linear regression models the relationship between two variables.
- We usually use x and y to model out equation.
- We estimate the relationship between the dependent variable (Y) and the independent variable (X) using a linear equation.
2024-10-20
The simple linear regression equation is modeled by: \[ Y = \beta_0 + \beta_1 X + \epsilon \]
library(ggplot2)
data <- data.frame(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
y = c(2, 5, 4, 7, 6, 9, 8, 11, 10, 12))
ggplot(data, aes(x = x, y = y)) +
geom_point() +
labs(title = "Scatterplot of X vs Y", x = "X", y = "Y")
## (Intercept) x ## 1.866667 1.006061
Using the equation from earlier: \[ Y = \beta_0 + \beta_1 X + \epsilon \]