[R] Error in randomForest.default(m, y, ...) : negative lengt h vectors are not allowed

Wiener, Matthew matthew_wiener at merck.com
Wed Dec 3 17:26:18 CET 2003


Christian -- 

You don't provide enough information (like a call) to answer this.  I
suspect, though, that you may be subsetting in a way that passes
randomForest no data.

I'm not aware offhand of an easy way to get this error from randomForest.  I
tried creating some data superficially similar to yours to see whether
something would break if there were only a single value in the variable to
be explained, but everything worked fine (though it does give a reasonable
warning).

> test.dat <- data.frame(a = rep(0, 1000), b = runif(1000), c = sample(0:1,
1000, replace = TRUE, p = c(.8, .2))
> t8 <- randomForest(a ~ b + c, data = test.dat)
Warning message: 
The response has five or fewer unique values.  Are you sure you want to do
regression? in: randomForest.default(m, y, ...) 
> test.dat[sample(1:1000, 100),"a"] <- runif(100, 1, 200)
> t8 <- randomForest(a ~ b + c, data = test.dat)

Some other generated data might come up with the error, but I'd bet on the
subsetting problem.

Hope this helps,  -Matt

Matthew Wiener
RY84-202
Applied Computer Science & Mathematics Dept.
Merck Research Labs
126 E. Lincoln Ave.
Rahway, NJ 07065
732-594-5303 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Christian Schulz
Sent: Wednesday, December 03, 2003 9:42 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Error in randomForest.default(m, y, ...) : negative length
vectors are not allowed


Hi,

what i'm doing wrong?
I'm using a data.frame with ~ 90.000 instances
and 7 attributes, 5 are binary recoded 
1 independend variable are a real one 
and the target is a real one,too.

The distributions are not very skewed in the dummy variables
,but in the real variables are ~ 60.000 
zero values instances, but zero means
no money is payed and is a important value!

Many thanks for help & suggestions,
regards,christian

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list