I am following an example in RPubs by Jose Vilardy but with different data. See
https://rpubs.com/josevilardy/crossvalidation
str(modelcv) command refers to $finalModel and $results.
caret train function with cv gives two RMSE values. What are they?
model <- as.formula("y ~ z + x2 + x4 + x5 + x6 + x10 + x11")
set.seed(12345)
library(caret)
train.control <- trainControl(method="cv",number=10)
modelcv <- train(model, data=train.data, method= "lm", trControl=train.control)
modelcv.Anova <- summary(modelcv)
modelcv.Anova
# (1) RMSE REPORTED AS RESAMPLED CROSS-VALIDATED
# is this rmse from training set?
modelcv
# (2) cross validated results is obtained using str() command.
# What is this? I am predicting using test.data.
RMSE_train.data <- modelcv$results$RMSE
pred <- predict(modelcv,test.data)
errorcv <- (pred - test.data$y)
RMSE_test.data <- sqrt(mean(errorcv^2))