0

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 :)

vog
  • 770
  • 5
  • 11
  • it could be easier for us to help you if you provide a self-contained example that we can replicate to see exactly the plot you are referring to :) – Álvaro A. Gutiérrez-Vargas Jan 18 '21 at 09:37
  • Now you can visualise the plot @ÁlvaroA.Gutiérrez-Vargas – vog Jan 18 '21 at 09:43
  • 1
    Thanks for the update. Unfortunately, I still cannot replicate your graph on my machine without sample data, hence my help here is limited only to guessing possible solutions. However, this question could help you https://stackoverflow.com/questions/53227676/partykit-how-to-plot-a-glmtree-without-overlapping-of-terminal-nodes?rq=1 – Álvaro A. Gutiérrez-Vargas Jan 18 '21 at 10:08
  • 1
    Usually I would say that you just have to plot on a device that is big enough to show everything. So something like `pdf("glmtr.pdf", height = 10, width = 20); plot(glmtr, terminal_panel = NULL); dev.off()` might work. Then you can use your PDF viewer to zoom into parts of the tree etc. – Achim Zeileis Jan 19 '21 at 00:17
  • OK, thanks for the follow-up. I've turned it now into an answer below so that you can accept it (by clicking the check mark on the left of the answer). Then SO flags the question as being resolved. – Achim Zeileis Jan 24 '21 at 16:39

1 Answers1

1

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()
Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49