[R] rpart.object help

jagdeesh_mn jagz8595 at gmail.com
Mon Dec 13 10:55:33 CET 2010



Prof Brian Ripley wrote:
> 
> On Sun, 12 Dec 2010, jagdeesh_mn wrote:
> 
>> Hi,
>>
>> Suppose i have generated an object using the following :
>> fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis)
>>
>> And when i print fit, i get the following :
>>
>> n= 81
>>
>> node), split, n, loss, yval, (yprob)
>>      * denotes terminal node
>>
>> 1) root 81 17 absent (0.7901235 0.2098765)
>>   2) Start>=8.5 62  6 absent (0.9032258 0.0967742)
>>     4) Start>=14.5 29  0 absent (1.0000000 0.0000000) *
>>     5) Start< 14.5 33  6 absent (0.8181818 0.1818182)
>>      10) Age< 55 12  0 absent (1.0000000 0.0000000) *
>>      11) Age>=55 21  6 absent (0.7142857 0.2857143)
>>        22) Age>=111 14  2 absent (0.8571429 0.1428571) *
>>        23) Age< 111 7  3 present (0.4285714 0.5714286) *
>>   3) Start< 8.5 19  8 present (0.4210526 0.5789474) *
>>
>> Is it possible to extract the splits alone as a matrix using
>> rpart.object?
>> If so, how?
> 
> What do you think 'rpart.object' is?  There is no such function in R.
> If you read help("rpart.object") it describes the returned object. 
> You are probably looking for fit$frame, but if you want something 
> else, study
> 
> rpart:::print.rpart
> 
> to see how that output is computed.
> 
>> Regards,
>> Jagdeesh
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> 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 at 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.
> 
> 

Thanks Mr. Brian. That kind of answers my query. 

On the same note I would like to ask few other questions. Sorry if you find
them naive, I am a novice in this subject and am trying to get a grip on
things. 

1. I am using R package using my code and the fitted object looks like this
:

The Model representation :
n= 60 

node), split, n, deviance, yval
      * denotes terminal node

 1) root 60 983551500 12615.670  
   2) dataFrame[, 6]='Small' 13  21804710  7682.385 *
   3) dataFrame[, 6]='Compact','Large','Medium','Sporty','Van' 47 557851600
13980.190  
     6) dataFrame[, 3]='Japan/USA','Korea','USA' 29 131050000 12673.030  
      12) dataFrame[, 6]='Compact','Sporty' 14  11426050 11055.570 *
      13) dataFrame[, 6]='Large','Medium','Van' 15  48812470 14182.670 *
     7) dataFrame[, 3]='France','Germany','Japan','Sweden' 18 297418200
16086.170 * 

What does the term deviance here stand for?

2. Could you also suggest me some readings on the topic of CnR trees
specific to R with case studies?

Regards,
Jagdeesh
-- 
View this message in context: http://r.789695.n4.nabble.com/rpart-object-help-tp3085054p3085183.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list