简体   繁体   中英

argument “fit” missing : R mob() in party package

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

Error in formals(fit) : argument "fit" is missing, with no default what exactly is meant by argument missing, kindly clarify

The model formula has to be a "formula" and not a "character" . So f needs to be defined without the quotes:

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

Or you can move it directly into the mob() call. Then you get this plot,

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

基于模型的递归分区

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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