2

I used this code,

tuneRF(x = mtry[,c(4:18)],
   y = mtry$Os, ntreeTry=50, stepFactor=2, 
   improve=0.05,trace=TRUE, plot=TRUE, doBest=FALSE)

And got the error:

Error in if (errorOld < 0) stop("Initial setting gave 0 error and no room for improvement.") :
argument is of length zero

What should I change?

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
s.tajik
  • 21
  • 2

1 Answers1

0

I ran into this same error when my I accidentally typed a column that didn't exist for the response column. Perhaps your mtry$Os column does not exist (it's hard to solve your problem w/o a reproducible example).

Example:

> library(randomForest)
> data("iris")
> tuneRF(x = iris[1:4,], y = iris$notacol)
Error in if (errorOld < 0) stop("Initial setting gave 0 error and no room for improvement.") : 
  argument is of length zero
Erin LeDell
  • 8,704
  • 1
  • 19
  • 35