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