Re: [R] party - ctree() - terminal nodes reference for every obs

From: Torsten Hothorn <Torsten.Hothorn_at_rzmail.uni-erlangen.de>
Date: Mon 17 Jul 2006 - 23:39:01 EST

On Fri, 14 Jul 2006, Daniele Medri wrote:

> Dear R.Users,
>
> using ctree() (from "party" library) on a data.frame, I want to append a
> column with the references for the groups/segments detected. While these
> nodes are easy readable in output, I need a vector for my obs.
>

Daniele,

do you mean a factor coding the terminal node numbers for each observation? This is the `where' slot in objects returned from `ctree', for example :

> airq <- subset(airquality, !is.na(Ozone))
> airct <- ctree(Ozone ~ ., data = airq,

+                         controls = ctree_control(maxsurrogate = 3))

> factor(airct@where)

   [1] 5 5 5 5 5 5 5 5 3 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 3 5 6 9 9 6 5 5 5 5 5 8 9
  [38] 6 8 9 8 8 8 8 5 6 6 3 6 8 8 9 3 8 8 6 9 8 8 8 6 3 6 6 8 8 8 8 9 8 9 6 6 5
  [75] 3 5 6 6 5 5 6 3 8 9 8 8 8 8 8 8 8 8 9 6 6 5 5 6 5 3 5 5 3 5 5 5 6 5 5 6 5
[112] 5 3 5 5 5
Levels: 3 5 6 8 9

Hope that helps,

Torsten

> Hints?
>
>
> Cheers
> --
> Daniele Medri
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 17 23:44:41 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 18 Jul 2006 - 00:16:33 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.