On Tue, 22 Jul 2008, Chua Siang Li wrote:
Hello there. I have fitted a rpart model.
> rpartModel <- rpart(y~., data=data.frame(y=y,x=x),method="class", ....)
and can use rpart$where to find out the terminal nodes that each
observations belongs.
Now, I have a set of new data and used predict.rpart which seems to give
only the predicted value with no information similar to rpart$where.
May I know how to find out the terminal nodes that each new observations
belongs to?
You need to read the code to answer questions about internals. A very
quick glance at predict.rpart would have told you that
where <- pred.rpart(object, rpart.matrix(newdata))
is what you are looking for. (Note that pred.rpart like many other
internal functions is not exported from the name space.)
Many thanks.
----
Chua Siang Li
Consultant - Operations Research
Acceval Pte Ltd
Tel: 6297 8740
Email: [EMAIL PROTECTED]
Website: www.acceval-intl.com
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
R-help@r-project.org 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.