Using the Boston dataset:
sample()
function to create a train set and store it in train
(sample 300 observations out of 506)lm.fit1
with medv
as the response and lstat
as the predictorlm.fit2
where you add a second order term of lstat
lm.fit3
where you add a second order and third order term of lstat
For each model calculate the validation \(MSE\) and store them in mse1
, mse2
and mse3
respectively
lm.fit1
lm.fit2
lm.fit3
Assume that:
MASS
library has been loadedBoston
dataset has been loaded and attached