Hi. I uses rpart to build a regression tree. Y is continuous. Now, I try
to predict on a new set of data. In the new set of data, one of my x (call
Incoterm, a factor) has a new level.
I wonder why the error below appears as the guide says "For factor
predictors, if an observation contains a level not used to grow the tree, it
is left at the deepest possible node and frame$yval at the node is the
prediction. "
Many thanks.
> mod <- rpart(y~., data=data.frame(y=y,x=x), method="anova",
+ cp=0.05, minsplit=100, minbucket=50, maxdepth=5)
> predictLost <- predict(mod, newdata=data.frame(y=yLost, x=xLost),
type="vector")
Error in model.frame.default(Terms, newdata, na.action = act, xlev =
attr(object, :
factor 'x.Incoterm' has new level(s) MTD
----
Chua Siang Li
Consultant - Operations Research
Acceval Pte Ltd
Tel: 6297 8740
Email: [EMAIL PROTECTED]
Website: www.acceval-intl.com
This message and any attachments (the "message"...{{dropped:13}}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.