Search code examples
rdecision-treeglmparty

Using terminal panels in plot() after glmtree()


enter image description hereUsing the recursive partitioning model for logit-trees in the following manner

library("partykit")
glmtr <- glmtree(formula = y~t + 1 | (variables)^2,
                 data = dff, 
                 minsize = 500,
                 maxdepth=4,
                 family = binomial)


plot(glmtr, terminal_panel = NULL)

I obtain a plot where the terminal panels overlap with each other and the visual interpretation of the treatment effects (t) turns difficult (specially when including the plot inside a document).

In order to make the plot more visual I have tried to reduce maxdepth=3. Even though this makes the trick, I lack of information as I am missing many leaves from the tree.

Is there a way to manually reduce the dimension of the terminal panels while keeping a certain number of leafs (e.g. maxdepth=4)?

That you in advance :)


Solution

  • In such a situation I recommend to plot the tree on a device that is big enough to show everything and where you can zoom easily etc. For example, one can plot into a big PDF file and then browse and zoom with the PDF viewer. Something like this should work ok:

    pdf("glmtr.pdf", height = 10, width = 20)
    plot(glmtr, terminal_panel = NULL)
    dev.off()