I am training a regression model using caret in R but I am having a hard time understanding how to validate the model. I am using postResample and it is outputting and RMSE and an R squared. I am honestly just confused as to what this function is doing and how it is getting these numbers. Is this an accurate way to validate a regression model or are there better ways? Below is code similar to what I am doing.
fitControl <- trainControl(## 10-fold CV
method = "repeatedcv",
number = 10,
## repeated ten times
repeats = 3)
car_t_index <- createDataPartition(mtcars$mpg, p = .8, list = FALSE, times = 1)
car_train <- mtcars[car_t_index,]
car_test <- mtcars[-car_t_index,]
model <- train(mpg ~ ., data = car_train,method = "rf", trControl = fitControl)
pred <- predict(model,car_test)
model
pred
postResample(pred = pred, obs = car_test$mpg)
```