2026-04-12

Introduction

  • Simple Linear Regression models the relationship between:
    • One predictor (X)
    • One response variable (Y)
  • It helps us:
    • Understand a lot of trends
    • Make certain predictions

Model Equation (Math Slide)

The simple linear regression model is:

\[ Y = \beta_0 + \beta_1 X + \epsilon \]

Where: - \(\beta_0\) = intercept
- \(\beta_1\) = slope
- \(\epsilon\) = random error

Least Squares Estimation (Math Slide)

We estimate coefficients by minimizing:

\[ \sum (y_i - \hat{y}_i)^2 \]

Estimated slope:

\[ \hat{\beta}_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2} \]

Example Dataset

We simulate data:

Regression Line fit

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

3D plot

Model summary

Call: lm(formula = y ~ x, data = data)

Residuals: Min 1Q Median 3Q Max -20.1120 -6.2223 -0.8193 6.6590 21.5966

Coefficients: Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.69016 2.68547 1.002 0.321
x 2.98643 0.09165 32.584 <2e-16 *** — Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05 ‘.’ 0.1 ’ ’ 1

Residual standard error: 9.353 on 48 degrees of freedom Multiple R-squared: 0.9567, Adjusted R-squared: 0.9558 F-statistic: 1062 on 1 and 48 DF, p-value: < 2.2e-16