You should get used to checking model quality visually. Look for inconsistencies between the data cloud pattern and the fitted lines for patterns in residuals and outlying observations. These exercises give examples and suggest R functions you can use for these tasks. This exercise does not count toward your grade. It is just for practice!
Exercises
-
Instead of using
lm()
to fit a straight line, you can useloess()
to fit a smooth curve. Repeat the process of model fitting, grid generation, predictions, and visualisation onsim1
usingloess()
instead oflm()
. How does the result compare togeom_smooth()
? -
add_predictions()
is paired withgather_predictions()
andspread_predictions()
. How do these three functions differ? -
What does
geom_ref_line()
do? What package does it come from? Why is displaying a reference line in plots showing residuals useful and important? -
Why might you want to look at a frequency polygon of absolute residuals? What are the pros and cons compared to looking at the raw residuals?
Source: H. Wickham and G. Grolemund, https://r4ds.had.co.nz/model-basics.html This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 3.0 License.