xpred.itree: Return Cross-Validated Predictions

Description Usage Arguments Details Value See Also Examples

View source: R/xpred.itree.R

Description

Gives the predicted values for an itree fit, under cross validation, for a set of complexity parameter values. Similar to xpred.rpart but will stop and print an error message when given a fit for which cp is not defined. If fit has a penalty, then all the cross-validations use the same penalty and penalization constant found in the fit object.

Usage

1
xpred.itree(fit, xval=10, cp)

Arguments

fit

a itree object.

xval

number of cross-validation groups. This may also be an explicit list of integers that define the cross-validation groups.

cp

the desired list of complexity values. By default it is taken from the cptable component of the fit.

Details

From rpart:
Complexity penalties are actually ranges, not values. If the cp values found in the table were .36, .28, and .13, for instance, this means that the first row of the table holds for all complexity penalties in the range [.36, 1], the second row for cp in the range [.28, .36) and the third row for [.13,.28). By default, the geometric mean of each interval is used for cross validation.

Value

A matrix with one row for each observation and one column for each complexity value.

See Also

itree

Examples

1
2
3
4
5
6
7
8
9
#rpart's example:
fit <- itree(Mileage ~ Weight, car.test.frame)
xmat <- xpred.itree(fit)
xerr <- (xmat - car.test.frame$Mileage)^2
apply(xerr, 2, sum)   # cross-validated error estimate

# approx same result as rel. error from printcp(fit)
apply(xerr, 2, sum)/var(car.test.frame$Mileage) 
printcp(fit)

itree documentation built on May 2, 2019, 7:25 a.m.

Related to xpred.itree in itree...