[R] rpart node number
Chua Siang Li
siang.li.chua at acceval-intl.com
Wed Jul 23 06:07:14 CEST 2008
Hello there. I have a tree with only 13 nodes. See my results below. How
do I get node number that is up to 33? Also, what happen to the missing
node number less than 13?
> rpartModel <- rpart(y~., data=data.frame(y=y,x=x),method="anova",
cp=0.005,
+ minsplit=100, minbucket=50, maxdepth=5)
> rpartModel
n= 1085
node), split, n, deviance, yval
* denotes terminal node
1) root 1085 1238057.00 -12.5980000
2) x.Incoterm=CFR,CIF,DDU,EXE,EXS,LTD 1023 864858.40 -16.9064800
4) x.Market.Price< 1727.5 824 627561.90 -22.5797100
8) x.Market.Price>=1345 625 349977.00 -31.6986700
16) x.Market.Price>=1602.5 177 152379.10 -43.5454200
32) x.Market.Price< 1647.5 50 14276.83 -74.3530000 *
33) x.Market.Price>=1647.5 127 71963.71 -31.4164600 *
17) x.Market.Price< 1602.5 448 162942.30 -27.0181500 *
9) x.Market.Price< 1345 199 62383.48 6.0602510
18) x.Market.Price>=1322.5 121 37167.00 0.6363636 *
19) x.Market.Price< 1322.5 78 16134.83 14.4742300 *
5) x.Market.Price>=1727.5 199 100960.60 6.5846730 *
3) x.Incoterm=DDP 62 40874.25 58.4919400 *
How do I get the node number printed only for the terminal nodes?
>plot(rpartModel,uniform=T,branch=1,compress=T,margin=0.1)
>text(rpartModel,pretty=1,all=T,use.n=T,cex=.6)
Thanks.
----
Chua Siang Li
Consultant - Operations Research
Acceval Pte Ltd
Tel: 6297 8740
Email: siang.li.chua at acceval-intl.com
Website: www.acceval-intl.com
This message and any attachments (the "message"...{{dropped:13}}
More information about the R-help
mailing list