In the lab, we applied random forests to the Boston data using mtry = 6 and using ntree = 25 and ntree = 500, with medv as dependent variable. Create a plot displaying the test error resulting from random forests on this data set for mtry, where \(m=p\), \(m=p/2\) and \(m=\sqrt{p}\). You can use the following code to split your data into train/test.

library(MASS)
library(randomForest)
set.seed(1)
train <- sample(1:nrow(Boston), nrow(Boston) / 2)
Boston.train <- Boston[train, -14]
Boston.test <- Boston[-train, -14]
Y.train <- Boston[train, 14]
Y.test <- Boston[-train, 14]

Your plot will not be tested by Dodona, you will still need to make it in order to answer the MC question.

Interpret the results obtained.

Questions



   - MC1: Does bagging perform better than random forest in this case?
       - 1: Yes
       - 2: No