title: caret:rfe get best performing variables for a certain size
body: <p>I ran a rfe Model with around 400 variables and got the result that the optimal model uses 40 variables. However, plotting the standard deviations of the error based on cross validation shows that the 40 variable model performs only slightly better than a model with only 10 variables. That's why I'd like to go for the model with 10 variables. I would like to use the 10 variables which perform best for a ten- variable-model and train the model again.</p>
  
  <p>How can I get the 10 variables which lead to the model performance shown in the rfe object?</p>
  
  <p>Since I use <code>rerank=TRUE</code>, I cannot just pick the 10 highest ranked variables from <code>varImp(rfeModel$fit)</code> right? (Would this work if I was not using "rerank" ?)</p>
  
  <p>I'm also struggling with the differences between the output from <code>varImp(rfeModel$fit)</code>, <code>varImp(rfeModel)</code>, <code>pickVars(rfeModel$variables,40)</code>.
  What is the right way to get the best performing variables with regard to the size of interest?</p>
  
  <p>The following example can be used:</p>
  
  <pre><code>data(BloodBrain)
  
  x &lt;- scale(bbbDescr[,-nearZeroVar(bbbDescr)])
  x &lt;- x[, -findCorrelation(cor(x), .8)]
  x &lt;- as.data.frame(x)
  
  set.seed(1)
  
  
  rfProfile &lt;- rfe(x, logBBB,
                   sizes = c(2, 5, 10, 20),
                   method="nnet",
                   maxit=10,
                   rfeControl(functions = caretFuncs,
                              returnResamp="all",
                              method="cv",
                              rerank=TRUE))
  </code></pre>
  
  <p><code>print(rfProfile)</code>, <code>varImp(rfProfile$fit)</code>, <code>varImp(rfProfile)</code>, <code>pickVars(rfProfile$variables, rfProfile$optsize)</code></p>