From: Davies, Bob (bdavies@intel.com)
Date: Thu 03 Jan 2002 - 09:23:02 EST
Message-id: <25A36276A29AD5119FB000508BB26843012C8D07@fmsmsx101.fm.intel.com>
Any rpart user:
I am trying to construct an rpart tree using a subset of the data and it
will occasionally fail when predicting a categorical response variable.
The reason that rpart fails is that the subset does not contain each of the
categories present in the original data. For example, in the car.test.frame
example, a subset that has all the categories except "Small" will not
produce an rpart tree.
I attempted to use "parms=list(prior=...) and it did not correct the
problem.
Here is a demonstration of the problem using the car.test.frame:
library(rpart)
data(car.test.frame)
t1 <- rpart(Type ~ ., car.test.frame)
t1
sub <- row.names(car.test.frame[car.test.frame[,"Weight"] > 2567.5,]) #
create a subset
rpart (Type ~ ., car.test.frame, subset=sub ) # this statement will fail
# so now attempt to indicate what the priors should look like:
rpart (Type ~ ., car.test.frame, subset=sub,
parms=list(prior=t1$parms$prior)) # this statement will fail
# now add 1 "Small" car to this subset of car.test.frame
sub <- row.names(car.test.frame[car.test.frame[,"Weight"] > 2559,]) # lower
the weight just a little to get a "Small" car.
rpart(Type ~ ., car.test.frame, subset=sub) # This statement will work !
Any suggestions?
I am using R 1.4.0 on Windows 2000.
Bob Davies
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:56:53 EST