Finish SLR + Introduce MLR
Lecture 15
Dr. Elijah Meyer
Duke University
STA 199 - Summer 2023
2023-10-19
Checklist
– Welcome Back :)
– Clone ae-14
– hw-5 released Tuesday Oct 24
– Lab next week: Project Proposal
Goals
– Finish SLR
– Introduce MLR
– Interpret coefficients
– Introduce the difference between additive and interaction models
Warm Up 1
– What is the difference between simple linear regression and multiple linear regression?
Warm Up 2
Interpret the slope coefficient in the context of the problem
library(tidyverse)
library(tidymodels)
library(palmerpenguins)
linear_reg() |>
set_engine("lm") |>
fit(body_mass_g ~ flipper_length_mm , data = penguins) |>
tidy()
# A tibble: 2 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) -5781. 306. -18.9 5.59e- 55
2 flipper_length_mm 49.7 1.52 32.7 4.37e-107
Warm Up 3 (Together)
Write our the estimated equation using proper notation.
Interpret the coefficient assocciated with the Dream
island.
library(tidyverse)
library(tidymodels)
library(palmerpenguins)
linear_reg() |>
set_engine("lm") |>
fit(body_mass_g ~ island, data = penguins) |>
tidy()
# A tibble: 3 × 5
term estimate std.error statistic p.value
<chr> <dbl> <dbl> <dbl> <dbl>
1 (Intercept) 4716. 48.5 97.3 8.93e-250
2 islandDream -1003. 74.2 -13.5 1.42e- 33
3 islandTorgersen -1010. 100. -10.1 4.66e- 21
Multiple Linear Regression
What happens if we want to include information from more than one variable to better explain our response?
– ae-14
— \(R^2\) review
— Fitting MLR models in R
Interaction vs Additive