I am using the party package in R.
I would like to get various statistics (mean, median, etc) from various nodes of the resultant tree, but I cannot see how to do this. For example
airq <- subset(airquality, !is.na(Ozone))
airct <- ctree(Ozone ~ ., data = airq,
controls = ctree_control(maxsurrogate = 3))
airct
plot(airct)
results in a tree with 4 terminal nodes. How would I get the mean airquality for each of those nodes?
This is surprisingly harder than I thought. Try something like this:
You might find some other useful examples with
?`BinaryTree-class`.