参数“fit”缺失:聚会包中的R mob()

时间:2015-12-29 19:00:08

标签: r party

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

形式错误(适合):缺少参数“fit”,没有默认值 究竟是什么意思缺失,请善意澄清

1 个答案:

答案 0 :(得分:2)

模型公式必须是"formula"而不是"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)

Model-based Recursive Partitioning