The reason that you don't see a difference is that you aren't using the caret
package. You do load it into your environment with the library()
command, but then you run randomForest()
which doesn't use caret.
I'll suggest starting by creating a data frame (or data.table) that contains only your input variables, and a vector containing your outcomes. I'm referring to the recently updated caret docs.
x <- data.frame(dat$Var1, dat$Var2, dat$Var3)
y <- dat$TargetVar
Next, verify that you have the parRF
method available. I didn't until I updated my caret package to the most recent version (6.0-29).
library("randomForest")
library("caret")
names(getModelInfo())
You should see parRF
in the output. Now you're ready to create your training model.
library(foreach)
rfParam <- expand.grid(ntree=100, importance=TRUE)
m <- train(x, y, method="parRF", tuneGrid=rfParam)