[R] Accessing terminal datasets in Ctree()
lordpreetam at gmail.com
Mon May 2 23:46:20 CEST 2016
Great, thank you so much Achim.
But one issue, in case I do not know how many terminal nodes would be
there, what do I do? Note that I do not need the datasets corresponding to
the intermediate nodes only need the terminal datasets.
On Tue, May 3, 2016 at 3:08 AM, Achim Zeileis <Achim.Zeileis at uibk.ac.at>
> On Mon, 2 May 2016, Preetam Pal wrote:
> Hi guys,
>> If I am applying ctree() on a data (specifying some control parameters
>> maxdepth), is there a way I can programmatically access the (smaller)
>> datasets corresponding to the terminal nodes in the tree? Say, if there
>> 7 terminal nodes, I need those 7 datasets (of course, I can look at the
>> respective node-splitting attributes and write out a filtering function -
>> but clearly too much to ask for if I have a large number of terminal
>> nodes). Intention is to perform regression on each of these terminal
> If you use the "partykit" implementation you can do:
> ct <- ctree(Species ~ ., data = iris)
> data_party(ct, id = 6)
> to obtain the data associated with node 6 for example. You can also use
> ct to obtain the subtree and ct$data for its associated data.
> For setting up a factor with the terminal node IDs, you can also use
> predict(ct, type = "node") and then use that in lm() etc.
> Finally, note that there is also lmtree() and glmtree() for trees with
> (generalized) linear models in their nodes.
>> Preetam Pal
>> M-Stat 2nd Year, Room No.
>> Statistics Division, C.V.Raman
>> Indian Statistical Institute, B.H.O.S.
>> [[alternative HTML version deleted]]
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
M-Stat 2nd Year, Room No. N-114
Statistics Division, C.V.Raman
Indian Statistical Institute, B.H.O.S.
[[alternative HTML version deleted]]
More information about the R-help