Simple linear regression models the relationship between two variables using a line.
\[ y = \beta_0 + \beta_1 x + \epsilon \]
2025-03-16
Simple linear regression models the relationship between two variables using a line.
\[ y = \beta_0 + \beta_1 x + \epsilon \]
The coefficients in a simple linear regression model are estimated by minimizing the sum of squared errors:
\[ \min_{\beta_0, \beta_1} \sum_{i=1}^{n} \left( y_i - (\beta_0 + \beta_1 x_i) \right)^2 \]
Here’s how to fit a model in R:
set.seed(123) x <- rnorm(100, mean = 5, sd = 2) y <- 2 + 3 * x + rnorm(100, mean = 0, sd = 3) data <- data.frame(x, y) model <- lm(y ~ x, data = data) summary(model)
Simple linear regression is a foundational tool in statistics, providing insight into the relationship between variables. We covered its formulation, key properties, mathematical derivation, and visualized both 2D and 3D examples.
Thank you for your attention!