Lab 4F
Directions: Follow along with the slides and answer the questions in red font in your journal.
lm()
models using straight lines into lm()
models using quadratic curves.movie
data and split it into two sets:
training
that includes 75% of the data.testing
that includes the remaining 25%.set.seed
.audience_rating
based on critics_rating
for the training
data.
testing
data and use add_line()
to include the line of best fit based on the training
data..critics_rating
that would make obviously poor predictions?testing
data and write it down for later.lm()
likey = a + bx
lm()
likey = a + bx + cx
2
R
, we can use the poly()
function.
audience_rating
using a quadratic polynomial for critics_rating
.2
in the poly()
function?y = a + bx + cx
2
testing
data.audience_rating
on the y-axis and critics_rating
on the x-axis using your testing
data.
training
data to the plot.audience_rating
using a 3
degree polynomial (called a cubic model) for the critics_rating
using the training data.
2
or 3
degree polynomial will make better predictions for the testing data.3
degree polynomial and use the MSE to justify whether the 2
or 3
degree polynomial fits the testing
data better.