[fbf06f]: / partyMod / tests / mob.R

Download this file

27 lines (21 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library("party")
data("BostonHousing", package = "mlbench")
BostonHousing$lstat <- log(BostonHousing$lstat)
BostonHousing$rm <- BostonHousing$rm^2
BostonHousing$chas <- factor(BostonHousing$chas, levels = 0:1, labels = c("no", "yes"))
BostonHousing$rad <- factor(BostonHousing$rad, ordered = TRUE)
fmBH <- mob(medv ~ lstat + rm | zn + indus + chas + nox + age + dis + rad + tax + crim + b + ptratio,
control = mob_control(minsplit = 40, verbose = TRUE),
data = BostonHousing, model = linearModel)
fmBH
summary(fmBH)
### check for one-node tree
fmBH <- try(mob(medv ~ lstat + rm | zn, control = mob_control(minsplit = 4000, verbose = TRUE),
data = BostonHousing, model = linearModel))
stopifnot(class(fmBH) != "try-error")
data("PimaIndiansDiabetes", package = "mlbench")
fmPID <- mob(diabetes ~ glucose | pregnant + pressure + triceps + insulin + mass + pedigree + age,
control = mob_control(verbose = TRUE),
data = PimaIndiansDiabetes, model = glinearModel, family = binomial())
fmPID
summary(fmPID)