0
library("caret")
library("randomForest")
library("party")
library("tree")
library("rpart")
library("rpart.plot")
library("survAUC")
library("survival")
options(digits=4)    
survivalTree<-ctree(Surv(survData$user_age,survData$is_user_active)~.,data=survData)
plot(survivalTree)

survData looks like this: enter image description here

it has alot more rows. and a-g are some kind of indicators which are in the nodes. user age is how long is the user in the system and alive or not is, as it says, alive or not (in our system).

With the above commands i've created a survivel ctree which looks like this: enter image description here

Now there are 7 leaves. I would like for each leaf, lets take the first leaf from the left for example: the variable n there is n = 17. i would like to add for (1,2,3) 17. so in that iteration 1,2,3 = 17. in the 4th iteration we are in the 4th leaf (from the left), n = 7. there i would like to add to (1,7,8,9) the value 7. so now 1 = 17+7=24. 2,3 = 17. and 7,8,9 = 7.

My problem is that i cannot reach the nodes as Ctree doesnt have a data-structure. Desired output is somthing like this:

a = 5001
b = 2232
c = 7110
d = 534
e = 223
f = 17
g = 6512

where a-g are factors in the 1st column of a data.frame and thier values are the 2nd column of that data.frame

Eran Moshe
  • 3,062
  • 2
  • 22
  • 41
  • First of all, you should provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data and make sure to be explicit about which libraries/packages you are using. I'm also confused about exactly what the desired output is here. Perhaps you could be more explicit about the structure of what you are after. – MrFlick Nov 08 '15 at 18:02
  • Tell me if you need me to add anything else – Eran Moshe Nov 08 '15 at 18:21
  • 1
    Still no data for this ... or for that matter the other question you asking. – IRTFM Nov 08 '15 at 19:41
  • Never mind, i've solved this. But I got another question..How do I get the 'n' value in each terminal node? like in node 4 n = 17 – Eran Moshe Nov 08 '15 at 19:44
  • That was the question I was looking at originally. – IRTFM Nov 08 '15 at 19:48

0 Answers0