Linear Regression

  • What is it?
    • Models the relationship between variables
  • Restrictions?
    • numeric data
    • sensitive to outliers
  • Assumptions?
    • normally distributed residuals
    • linear relationship

How is Linear Regression Calculated?

  • Line of Best Fit \[ \hat{y} = \beta_0 + \beta_1 x \]
  • Least Squares Method
    • Minimize Residuals \[ Residual = y_i - \hat{y}_i \]
  • Mean Squared Error
    • Find average of squared residuals \[ MSE = \frac{1}{n}\sum_{i=1}^{n} (y_i - \hat{y}_i)^2 \]

Penguins Dataset

Using the Penguins Dataset: Code

penguin_model <- lm(
  body_mass_g ~ flipper_length_mm,
  data = penguins
)

penguin_model
## 
## Call:
## lm(formula = body_mass_g ~ flipper_length_mm, data = penguins)
## 
## Coefficients:
##       (Intercept)  flipper_length_mm  
##          -5872.09              50.15

Using the Penguins Dataset: Plot 1

Using the Penguins Dataset: Plot 2

Using the Penguins Dataset: Plot 3