繁体   English   中英

R-partykit树的nodes()问题

[英]R - Problems with nodes() for a partykit tree

我有一个类似的问题

如何获得所有终端节点-R中的权重和响应预测'ctree'

我想得到这样的结果。 但是,在我的情况下,nodes()函数无法正常工作。 而且我不明白为什么。

tree <- ctree(DV ~ IV, data = data)

nodes(tree, unique(where(tree))) 

当我运行它时,我总是得到以下错误:

Error in match.arg(data, choices = c("all", "organization", "endpoint",  : 
  'arg' must be NULL or a character vector

为了使该功能正常工作,我该怎么办?

提前非常感谢您!

尝试使用party包的ctree函数:

library(party)
set.seed(1)
x <- rnorm(100)
y <- x+runif(100)
data <- data.frame(DV=y , IV=x)

tree <- party::ctree(DV ~ IV, data = data)
nodes(tree, unique(where(tree))) 

# [[1]]
# 3)*  weights = 19 

# [[2]]
# 6)*  weights = 26 

# [[3]]
# 9)*  weights = 19 

# [[4]]
# 8)*  weights = 19 

# [[5]]
# 5)*  weights = 17

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM