R Part 5

The total length of the videos in this section is approximately 43 minutes, but you will also spend time running code while completing this section.

You can also view all the videos in this section at the YouTube playlist linked here.

Please download the two code files below in order to follow along with the videos.

Graphically checking whether logs would help

RPart5.1.mp4

Question 1: Which assumptions can be made more true by logging one or both variables?

Show answer

linearity, equal variance, possibly normality

Voltage example

RPart5.2.mp4

Question 2: What happens if you have a bunch of dots along a curve, and you connect them in the wrong order?

Bands, and how to make and interpret residual v. fitted value plots

RPart5.3.mp4

Question 3: When are residual v. fitted value plots most useful?

Show answer

When you have multiple predictors and can't make one scatterplot to check the regression assumptions. No matter how many predictors you have, every data point will have one residual and one fitted value.

predict function for linear regression

RPart5.4.mp4

Question 4: Given a linear regression, if you don't specify a new data set to make predictions for, or if there is an error in your specification of a new data set, what does the predict function do?

Show answer

The predict function will output the fitted values for the data points used to fit the model.

predict function for trees and splines

RPart5.5.mp4

Question 5: If you have a spline instead of a tree or lm, what is the "new" argument called?

Show answer

It is called "x".

That's it.

During this tutorial you learned:


Terms and concepts:

Log transformation, confidence interval, prediction interval, residuals versus fitted values plot


Functions in review:

exp(), log(), qt(), order(), predict()