Hi, I'm trying to find the optimal "mtry" value for a Random Forest classifier on a given set of training and test data. I want to plot the error rate on the test data and oob error on the raining data for each value of "mtry" but the plot won't show the line corresponding to the oob.error, does anyone know what mistake i've made?
oob.err = double(10)
test.err = double(10)
for(mtry in 1:10)
{
model = randomForest(train[,1]~., data = train[,-1], mtry=mtry, ntree = 400)
oob.err[mtry] = model$err.rate[400,1]
pred = predict(model, test[,-1])
test.err[mtry] = with(test[,-1], mean( (test[,1]-pred)^2 ))
}
Thanks