A simple function to take the output of a partition model created with rpart and return information abouthe complexity parameter and performance of varies models.
getcp(TREE)
Arguments
TREE: An object of class rpart. This is created by making a partition model using rpart.
Details
This function prints out a table of the complexity parameter, number of splits, relative error, cross validation error, and standard deviation of cross validation error for a partition model. It adds helpful advice for what the value of CP is for the tree that had the lowest cross validation error and also the value of CP for the simplest tree with a cross validation error at most 1 standard deviation above the lowest.
Further, a plot is made of the estimated generalization error (xerror) versus the number of splits to illustrate when the tree stops improving. Vertical lines are draw at the number of splits corresponding to the lowest estimated generalization error to the tree selected by the one standard deviation rule.
References
Introduction to Regression and Modeling
Author(s)
Adam Petrie
See Also
rpart
Examples
data(JUNK) TREE <- rpart(Junk~.,data=JUNK,control=rpart.control(cp=0,xval=10,minbucket=5)) getcp(TREE)