This exercise involves the use of simple linear regression on the College
data set.
The dataset is available in the ISLR2
library.
Note: this exercise is primarily based on the lab of chapter 3 (Linear Regression).
Some of the exercises are not tested by Dodona (for example the plots),
but it is still useful to try them.
Answer the multiple choice questions by e.g. typing MC1 <- 1
if you think answer 1 of MC1 is correct.
Use the lm()
function to perform a simple linear regression with the number of applications (Apps
)
as the response and the number of accepted applications (Accept
) as the predictor. Store the model in lm.fit1
.
Use the summary()
function to print the results.
What is the predicted Apps
associated with an Accept
of 2000? Store the answer in pred
.
What are the associated 95% confidence and prediction intervals of the prediction with an Accept
of 2000?
Store the answers in conf.int.95
and pred.int.95
.
Accept
hints at a weak relationship between Accept
and Apps
.Accept
is positive, we can conclude that the more Accept
a university has,
the higher the Apps
will be (on average).
Plot the response and the predictor with the plot()
function. Use the abline()
function
to display the least squares regression line.
poly
function with default argument raw=FALSE
):
lm.fit2
: a second-order polynomial of Accept
.lm.fit3
: a third-order polynomial of Accept
.
college.anova
.lm.fit1
lm.fit2
lm.fit3
Assume that:
ISLR2
library has been loadedCollege
dataset has been loaded and attached