2025-03-16

What is Simple Linear Regression?

Simple linear regression models the relationship between two variables using a line.
\[ y = \beta_0 + \beta_1 x + \epsilon \]

Least Squares Estimation

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 \]

Usage

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)

Properties

  • Linearity: The relationship between the variables is represented by a straight line.
  • Constant Slope: The slope beta1 remains the same throughout.
  • Intercept: The value of y when x = 0 (i.e., beta0).
  • Deterministic Trend: In the absence of random noise, the relationship is entirely determined by beta0 and beta1.
  • Predictability: Once fitted, the model can predict y for given values of x.

Example (yay)

Another One

3d Example

Conclusion

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!