[R] extracting ctree() output information

Achim Zeileis Achim.Zeileis at uibk.ac.at
Wed Apr 7 22:57:07 CEST 2010

On Wed, 7 Apr 2010, Steven J. Clark wrote:

> Hi,
> I am new to R and am using the ctree() function to do customer
> segmentation.  I am using the following code to generate the tree:
> treedata$Response<-factor(treedata$Conversion)
> fit<-ctree(Response ~
> .,controls=ctree_control(mincriterion=0.99,maxdepth=4),data=treedata)
> plot(fit)
> print(fit)
> The variable "Response" above equals 1 if the customer responded to an
> offering and 0 otherwise.  Everything works great, however I am
> struggling to extract the information I need from the output.  When I
> look at the output from print(fit) I see things similar to:
> 4) age <=42; criterion 1, statistic = 73.055
>  5)* weights = 5843
> What this is telling me is that 5,843 customers ended up being
> classified into the group labeled 5.  What I would really like to know,
> however, is what proportion of this 5,843 had Response=1 and what
> proportion had Response=0 so that I could make some inference about the
> P(Response) for customers that match the demographic characteristics of
> each terminal node.

especially the examples section. With where(fit) you can query the node 
number and with treeresponse(fit) you get a list with the frequency 
distribution. There are also some worked examples how you can compute 
other quantities of interest.


> Any help on how to extract this information would be greatly appreciated
> -- thanks!
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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.

More information about the R-help mailing list