Modelbased recursive partitioning based on generalized linear models.
1 2 
formula 
symbolic description of the model (of type

data, subset, na.action 
arguments controlling formula processing
via 
weights 
optional numeric vector of weights. By default these are
treated as case weights but the default can be changed in

offset 
optional numeric vector with an a priori known component to be
included in the model 
cluster 
optional vector (typically numeric or factor) with a cluster ID to be employed for clustered covariances in the parameter stability tests. 
family 
specification of a family for 
epsilon, maxit 
control parameters passed to

... 
optional control parameters passed to

Convenience interface for fitting MOBs (modelbased recursive partitions) via
the mob
function. glmtree
internally sets up a model
fit
function for mob
, using glm.fit
.
Then mob
is called using the negative loglikelihood as the objective
function.
Compared to calling mob
by hand, the implementation tries to avoid
unnecessary computations while growing the tree. Also, it provides a more
elaborate plotting function.
An object of class glmtree
inheriting from modelparty
.
The info
element of the overall party
and the individual
node
s contain various informations about the models.
Zeileis A, Hothorn T, Hornik K (2008). ModelBased Recursive Partitioning. Journal of Computational and Graphical Statistics, 17(2), 492–514.
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 26 27 28 29 30 31 32 33 34 35 36 37  if(require("mlbench")) {
## Pima Indians diabetes data
data("PimaIndiansDiabetes", package = "mlbench")
## recursive partitioning of a logistic regression model
pid_tree2 < glmtree(diabetes ~ glucose  pregnant +
pressure + triceps + insulin + mass + pedigree + age,
data = PimaIndiansDiabetes, family = binomial)
## printing whole tree or individual nodes
print(pid_tree2)
print(pid_tree2, node = 1)
## visualization
plot(pid_tree2)
plot(pid_tree2, tp_args = list(cdplot = TRUE))
plot(pid_tree2, terminal_panel = NULL)
## estimated parameters
coef(pid_tree2)
coef(pid_tree2, node = 5)
summary(pid_tree2, node = 5)
## deviance, loglikelihood and information criteria
deviance(pid_tree2)
logLik(pid_tree2)
AIC(pid_tree2)
BIC(pid_tree2)
## different types of predictions
pid < head(PimaIndiansDiabetes)
predict(pid_tree2, newdata = pid, type = "node")
predict(pid_tree2, newdata = pid, type = "response")
predict(pid_tree2, newdata = pid, type = "link")
}

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.