[R] rpart, cross-validation errors question

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon May 3 09:10:20 CEST 2010



On 03.05.2010 04:26, Claudia Penaloza wrote:
> I ran this code (several times) from the Quick-R web page (
> http://www.statmethods.net/advstats/cart.html) but my cross-validation
> errors increase instead of decrease (same thing happens with an unrelated
> data set).
>
> Why does this happen?

Since the classes are not well separable along the dimensions using the 
provided variables?


> Am I doing something wrong?

Wrong is that you expect the result to be always better if the tree is 
larger.

Try the iris data, for example, and find that your assumptions are not 
always wrong. ;-)

Best wishes,
Uwe


> # Classification Tree with rpart
> library(rpart)
>
> # grow tree
> fit<- rpart(Kyphosis ~ Age + Number + Start,
>     method="class", data=kyphosis)
>
> printcp(fit) # display the results
> plotcp(fit) # visualize cross-validation results
>
>
> Thank you,
> Claudia
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list