Predictions from a Fitted Arbor Object

DESCRIPTION:

Returns a vector of predicted responses or an arbor object from a fitted arbor object.

USAGE:

predict.arbor(object, newdata=list(),
              type=c("vector", "matrix", "tree", "class", "prob"))

REQUIRED ARGUMENTS:

object
fitted model object of class arbor. This is assumed to be the result of some function that produces an object with the same named components as that returned by the arbor function.

OPTIONAL ARGUMENTS:

newdata
data frame containing the values at which predictions are required. The predictors referred to in the right side of formula(object) must be present by name in newdata. If missing, the fitted values are returned.
type
character string denoting how the predictions are returned. The default is matrix for longitudinal data and vector for all other data.

VALUE:

if type="vector": vector of predicted responses.

if type="matrix": either a matrix of predicted class probabilities and class counts (for classification problem), or number of events at a node (for poisson or exponential methods), along with the predicted responses or predicted responses for longitudinal data. If the input object does not have a yval2 (i.e. anova method was used) then the vector of predicted responses is returned.

if type="tree" : an object of class arbor with new values for frame$n and frame$yval (and frame$yprob if it exists). This options does not currently work.

if type="class" : vector of predicted factor responses, if method is classification.

if type="prob": returns a vector or a matrix (as appropriate) of class probabilities.

DETAILS:

This function is a method for the generic function predict for class arbor . It can be invoked by calling predict for an object of the appropriate class, or directly by calling predict.arbor regardless of the class of the object.

The new object is obtained by dropping newdata down object. For factor predictors, if an observation contains a level not used to grow the tree, it is left at the deepest possible node and frame$yval at the node is the prediction.

SEE ALSO:

,

EXAMPLES:

z.auto <- arbor(Mileage ~ Weight, car.test.frame)
predict(z.auto)

# To obtain the response as factors:
fit1 <- arbor(Kyphosis ~ Age + Number + Start, data=kyphosis)
ylevels <- attr(fit1, 'ylevels')
predFactors <- factor(ylevels[fit1$frame$yval[fit1$where]], levels=ylevels)
names(predFactors) <- names(fit1$where)
predFactors  # this will be the same as predict(fit1, type='class')