Resampling methods
set.seed(): random number generator (so that the results obtained can be reproduced precisely later)
sample(): randomly selecting data of size ‘n’ from the dataset
Selecting random subset of 196 out of original 392 observations
392 observations = training set
split observations into two halves
predict(): estimate response for all 392 observations
mean(): calculate MSE of the 196 observations in validation set
-train: selects only observations that are not in training set
poly(): estimate test error for polynomial and cubic regressions
glm() and cv.glm(): computes any generalized linear model
glm(): performs logistic regression by passing in family = “binomial”
glm(): performs linear regression when there is no family argument (=lm())
set.seed(): random number generator (so that the results obtained can be reproduced precisely later)
sample(): randomly selecting data of size ‘n’ from the dataset
Selecting random subset of 196 out of original 392 observations
392 observations = training set
split observations into two halves
predict(): estimate response for all 392 observations
mean(): calculate MSE of the 196 observations in validation set
-train: selects only observations that are not in training set
poly(): estimate test error for polynomial and cubic regressions
glm() and cv.glm(): computes any generalized linear model
glm(): performs logistic regression by passing in family = “binomial”
glm(): performs linear regression when there is no family argument (=lm())