2
$\begingroup$

I am working with the ctree function that is implemented in R in the party and partykit packages, and I have a question about working with the output. Here is an elementary example:

x <- ctree(mpg~.,mtcars)
plot(x)

enter image description here

If I understand correctly, the function uses its recursive algorithm to generate the splits, and then fits a regression for the distribution at each terminal node. A predicted value is generated by finding the the terminal node associated with the input, and then finding the predicted value from that regression.

Am I correct in assuming the algorithm generates a separate regression for each terminal node? So for example, predicting the value for a car with wt>2.32 would simply mean using the regression associated with the distribution in node 2. Similarly, for a car with wt<2.32 and disp<258 would use the regression from Node 4.

The plot gives me the distribution at each terminal node, but is it possible to extract the actual regression coefficients associated with a terminal node or am I misunderstanding how ctree works?

Kind Regards

$\endgroup$

1 Answer 1

2
$\begingroup$

In conditional inference trees there is no regression model fitted in the nodes (unless you use a non-standard transformation function). Thus, in your example the prediction is simply based on the mean of the response in each terminal node.

If you want to fit a tree with regression models in each node, consider using lmtree or glmtree from the partykit package (based on the mob algorithm).

$\endgroup$
3
  • $\begingroup$ +1 Thanks for answering this one, Achim. You'd certainly be best placed to know (since you're a coauthor on the package), but this suggests that the index page for the documentation of party may be misleading for newcomers. It says: "The core of the package is ctree(), an implementation of conditional inference trees which embed tree-structured regression models into..." . It would hardly be a surprise if people interpreted that as doing regression at each node; indeed "embed" sees to suggest it. $\endgroup$
    – Glen_b
    Nov 19, 2015 at 22:55
  • $\begingroup$ Hmmm, ctree is still a regression tree (like rpart is), it just has a simple intercept-only model in each node. So the quote seems to fit and we didn't have many of such questions so far. But I'll have a look at whether we can improve the docs further. $\endgroup$ Nov 19, 2015 at 23:37
  • $\begingroup$ I'd assume that the use of the word regression in the sentence there was really intended to refer to the model as a whole (which is a form of regression in the sense that globally it's a model for E(Y|predictors)... where in effect step-functions are being fitted); it's just that it's easy to read it as per-node regression there. $\endgroup$
    – Glen_b
    Nov 19, 2015 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.