1
#Logistic Model Based Recursive Partitioning
library(party)
data("PimaIndiansDiabetes2",package = "mlbench")
set.seed(16)
n=nrow(PimaIndiansDiabetes2)
train <- sample(1:n, 600, FALSE)
#mass and pedigree are conditioning varibles for logistic regression
f<-"diabetes ~ mass + pedigree|glucose + pregnant + pressure + triceps +
insulin + age"
fit <- mob(f, data=PimaIndiansDiabetes2[train, ], model=glinearModel, family=binomial())
plot(fit)

形式错误(适合):缺少参数“适合”,没有默认参数缺少的确切含义,请澄清

4

1 回答 1

2

模型公式必须是 a"formula"而不是 a "character"。所以f需要在没有引号的情况下定义:

f <- diabetes ~ mass + pedigree | glucose + pregnant + pressure + triceps + insulin + age

或者,您可以将其直接移动到mob()通话中。然后你得到这个情节,

# mass and pedigree are conditioning variables for logistic regression
fit <- mob(diabetes ~ mass + pedigree | glucose + pregnant + pressure + triceps + insulin + age, 
  data = PimaIndiansDiabetes2[train, ], model = glinearModel, family = binomial())
plot(fit)

基于模型的递归分区

于 2015-12-29T19:07:16.923 回答