I would like to get the survival objects which are created by the ctree function.
The reason is that I would like to get the vectors which describe the curves in each leaf of the tree.
Does anyone know how to do that?
Thanks in advance!
Alley
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get at the curves using the
treeresponsemethod. There might be a much better way, but this is what I came up with.Here is an illustration using the example of a survival tree from
?ctree:We grab the (fitted) responses, using
treeresponsefor the training data. This is a list, with a component for each observation in the training data.Each component out
outis a survival object, class"survfit"For this tree we have four terminal nodes, so there are only four unique survival objects. You can use the
wheremethod to see which nodes the observations were inWe can use this index the unique survival objects. For example, for node 3 (the leftmost node in the plot of the tree)
The survival curve for node 3 can be plotted using the
plotmethod:which, apart from the range on the axes is the plot used in the panel for node 3 on the tree drawn earlier.
For this example, you can repeat for nodes 4, 6 and 7, but you’ll need to tailor which nodes you work with to your data and fitted tree.