rpart(formula, data, weights, subset, na.action = na.rpart, method, model = FALSE, x = FALSE, y = TRUE, parms, control, cost, ...)
yis missing, but keeps those in which one or more predictors are missing.
methodis missing then the routine tries to make an intelligent guess. If
yis a survival object, then
method = "exp"is assumed, if
yhas 2 columns then
method = "poisson"is assumed, if
yis a factor then
method = "class"is assumed, otherwise
method = "anova"is assumed. It is wisest to specify the method directly, especially as more criteria may added to the function in future.
method can be a list of functions named
eval. Examples are given in
the file tests/usersplits.R in the sources, and in the
vignettes User Written Split Functions.
modelis a model frame (likely from an earlier call to the
rpartfunction), then this frame is used rather than constructing new data.
xmatrix in the result.
modelis supplied this defaults to
prior), the loss matrix (component
loss) or the splitting index (component
split). The priors must be positive and sum to 1. The loss matrix must have zeros on the diagonal and positive off-diagonal elements. The splitting index can be
information. The default priors are proportional to the data counts, the losses default to 1, and the split defaults to
rpart.controlmay also be specified in the call to
rpart. They are checked against the list of valid arguments.
treefunction in S mainly in its handling of surrogate variables. In most details it follows Breiman et. al (1984) quite closely. R package tree provides a re-implementation of
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis) fit2 <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis, parms = list(prior = c(.65,.35), split = "information")) fit3 <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis, control = rpart.control(cp = 0.05)) par(mfrow = c(1,2), xpd = NA) # otherwise on some devices the text is clipped plot(fit) text(fit, use.n = TRUE) plot(fit2) text(fit2, use.n = TRUE)