Prediction variable in random Forest data set I am doing regression with random forest (randomForest library), my question is if in my test_set do I have to include the prediction variable? For example, my prediction variable is X and my training set has variables X, Y, Z, A, B, when I want to apply the random forest to a new data, should I include the prediction variable X, or should I only use Y, Z, A, B?
yhatCom.rf = predict(rf_, test_set)
If I have to include the prediction variable, and since it is the value that I am trying to predict, which value should I use?
Thank you
 A: It does not make any difference.  Try this code with and without the prediction variable in the testset:
library(randomForest)
data(iris)
set.seed(111)
ind <- sample(2, nrow(iris), replace = TRUE, prob=c(0.8, 0.2))
trainset <- iris[ind == 1,]
testset1 <- iris[ind == 2,]          # with   Species column
testset2 <- iris[ind == 2, -5]       # remove Species column
iris.rf <- randomForest(Species ~ ., data=trainset)
iris.pred1 <- predict(iris.rf, testset1)
iris.pred2 <- predict(iris.rf, testset2)

Then the predictions are identical 
> iris.pred2 == iris.pred1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

and they are reasonable 
> table(observed = iris[ind==2, "Species"], predicted = iris.pred1)
            predicted
observed     setosa versicolor virginica
  setosa          5          0         0
  versicolor      0          8         2
  virginica       0          1        14
> table(observed = iris[ind==2, "Species"], predicted = iris.pred2)
            predicted
observed     setosa versicolor virginica
  setosa          5          0         0
  versicolor      0          8         2
  virginica       0          1        14

(you would get slightly different results with a different seed and so different training and test sets)
