s-news
[Top] [All Lists]

Re: using Rpart to obtain trees with given size

To: kyu@mail.mpi.com
Subject: Re: using Rpart to obtain trees with given size
From: Terry Therneau <therneau@mayo.edu>
Date: Wed, 20 Feb 2002 16:04:10 -0600 (CST)
Cc: s-news@wubios.wustl.edu
Reply-to: Terry Therneau <therneau@mayo.edu>
 Kai Yu asks:
 
 I am trying to build a tree model using rpart. I need a way to get the
tree with any given number of splits. Checking the cp table (using 
printcp) can't help in many cases. For example, given the following CP
table,
        CP nsplit rel error xerror     xstd 
1 0.050633      0   1.00000 1.0000 0.036718
2 0.035443      1   0.94937 1.0734 0.036796
3 0.022785      3   0.87848 1.0810 0.036794
4 0.020253      7   0.78228 1.0633 0.036795

I can't get a tree with the best 2 splits.
 
----------------------------------------------------------

 No, you can't get said tree.  Neither can I. 
 You need to read the tree literature (I'd recommend the CART book by
Brieman, Friedman, Olshen and Stone).
  In the case you display, there is not a `best' 2 split tree according to
the complexity ordering.  If you did summary(fit) you would notice that
every split is labeled with a complexity parameter, and that some of them
are tied.  Hence there is no cutoff value that trims exactly the number
of nodes that you desire.

        Terry Therneau
        


<Prev in Thread] Current Thread [Next in Thread>