我有与
类似的问题how to get all terminal nodes - weight & response prediction 'ctree' in r
我想得到这样的结果。然而,在我的情况下,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
为了使功能有效,我该怎么做?
非常感谢你!
答案 0 :(得分:0)
尝试使用ctree
包的party
功能:
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