Slope (dream) : Holding flipper length constant, we expect, on average, a penguin from the Dream island to be 262g lighter than a penguin from Biscoe island.
The Interaction Model
The interaction model: different slopes for each island
bm_fl_island_int_fit<-linear_reg()|>fit(body_mass_g~flipper_length_mm*island, data =penguins)tidy(bm_fl_island_int_fit)|>select(term, estimate)
We can interpret each of the lines just as we would a simple linear regression, keeping in mind that we are only looking at penguins from one specific island.
This, we have done. It is what R naturally does when we use color = island!
A note on plotting…
This, we have not! Here, we use the predicted y values (attained using augment) from an additive model in geom_smooth().
A note on plotting…
# Fit Model and use Augmentbm_fl_island_fit<-linear_reg()|>fit(body_mass_g~flipper_length_mm+island, data =penguins)bm_fl_island_aug<-augment(bm_fl_island_fit, new_data =penguins)# Additive modelggplot(bm_fl_island_aug, aes(x =flipper_length_mm, y =body_mass_g, color =island))+geom_point(alpha =0.5)+geom_smooth(aes(y =.pred), method ="lm")+labs( title ="Plot A - Additive model", x ="Flipper Length (mm)", y ="Body Mass (g)", color ="Island")+theme( legend.position ="bottom", plot.title =element_text(size =18, face ="bold"), axis.title =element_text(size =16), axis.text =element_text(size =14), legend.title =element_text(size =14), legend.text =element_text(size =12))
Multiple numeric predictors
Multiple Numerical Predictors
What if we want to use multiple numerical predictors to model a numerical outcome?
Example:
Using flipper length and bill length to predict body mass.
Using Rotten Tomato critic score + metacritic score to predict audience score
So many more!!
Multiple Numerical Predictors: Example
bm_fl_bl_fit<-linear_reg()|>fit(body_mass_g~flipper_length_mm*bill_length_mm, data =penguins)tidy(bm_fl_bl_fit)
We predict that the body mass of a penguin with zero flipper length and zero bill length will be -5736 grams, on average (makes no sense);
Holding all other variables constant, for every additional millimeter in flipper length, we expect the body mass of penguins to be higher, on average, by 48.1 grams.
Holding all other variables constant, for every additional millimeter in bill length, we expect the body mass of penguins to be higher, on average, by 6 grams.
. . .
This is how we interpret additive models with as many predictors as we want!