Lab 4B
Directions: Follow along with the slides, completing
the questions in blue on your
computer, and answering the questions in red in your
journal.
Space, Click, Right Arrow or swipe left to move to
the next slide.
arm_span
data again.
xyplot
with
height
on the y-axis and armspan
on the
x-axis.add_line()
to run the
add_line
function; you’ll be prompted to click twice in the
plot window to create a line that you think fits the data
well.height
s based on
their armspan
:arm_span
data.arm_span
.What do the residuals measure?
One method we might consider to measure our model’s accuracy is to sum the residuals.
Fill in the blanks below to calculate our accuracy summary.
mutate
, the first argument of
summarize
is a dataframe, and the second argument is the
action to perform on a column of the dataframe. Whereas the output of
mutate
is a column, the output of summarize
is
(usually) a single number summary.height
and
armspan
.
best_fit
.
R
is familiar with is
simpler than with lines, or models, we come up with ourselves.
best_fit
:predict
function takes a linear model as
input, and outputs the predictions of that model.lm()
function creates the line of best fit
equation by finding the line that minimizes the mean squared
error. Meaning, it’s the best fitting line possible.
add_line()
to the same value you calculated
using the lm
function.lm
line in terms of the MSE. Were any of them
successful?lm
line fits your
data, create a scatterplot and then run: