partykit-如何在不重叠终端节点的情况下绘制glmtree? [英] partykit - How to plot a glmtree without overlapping of terminal nodes?

查看:61
本文介绍了partykit-如何在不重叠终端节点的情况下绘制glmtree?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一棵由glmtree(partykit软件包)产生的树.不幸的是,终端节点重叠并且图形的标签不再正确显示.

I would like to plot a tree resulting from glmtree (partykit package). Unfortunately, the terminal nodes are overlapping and the labels of the graphs are no longer displayed properly.

生成树的代码是这样的:

The code that generates the tree is this one:

library(partykit)
library(aVirtualTwins)

data(sepsis)
attach(sepsis)

data <- cbind(y = survival, trt = as.factor(THERAPY), sepsis[,3:13])
formula <- as.formula(paste("y ~ trt", paste(names(sepsis[,3:13]), 
                            collapse = " + "), sep = " | "))
fit <- glmtree(formula, data, family = binomial)

plot(fit)

detach(sepsis)

是否有一种方法可以自定义plot()的输出以避免终端节点重叠?

Is there a way to customize the output of plot() in order to avoid overlapping of the terminal nodes?

这是我的意思的图片:

Here is a picture of what I mean:

推荐答案

glmtree 对象(以及其他 partykit )的 plot()输出>对象)可通过面板功能针对树的所有方面(内部节点,终端节点,边缘等)进行自定义.默认情况下,用于这种树的面板函数是 node_bivplot(),它具有许多可以调整的参数.有关详细信息,请参见?node_bivplot .例如,此处的相关选项是 ylines ,您可以将其增加到 2 .

The plot() output for glmtree objects (and also other partykit objects) is customizable through panel functions for all aspects of the tree (inner nodes, terminal nodes, edges, ...). The panel function employed by default for this kind of tree is node_bivplot() which has a number of arguments that can be tweaked. See ?node_bivplot for details. The relevant option here is ylines that you can increase to 2, for example.

可以将参数传递给终端面板功能 tp_args :

To pass arguments to the terminal panel functiontp_args can be used:

plot(fit, tp_args = list(ylines = 2))

这篇关于partykit-如何在不重叠终端节点的情况下绘制glmtree?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆