[R] CV by rpart/mvpart

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 29 08:18:34 CET 2006


On Thu, 28 Dec 2006, Weiwei Shi wrote:

> n-fold cv is easy to be implemented in R by yourself. you can create
> 10 folds' samples by yourself and disable cv in rpart. Then you can
> use the same sample sets to compare different methods.

BUT, rpart uses CV to select the cost-complexity parameter, so you need 
not to disable its internal CV or you are not using rpart.  CV for 
parameter tuning and CV for validation are not the same thing.

There are examples of using n-fold CV for validation, including with 
trees, in MASS4.

>
> HTH
>
> weiwei
>
> On 12/28/06, Pedro Ramirez <palmar379 at yahoo.es> wrote:
>> Dear R-list,
>>
>> I am using the rpart/mvpart-package for selecting a right-sized 
>> regression tree by 10-fold cross-validation. My question: Is there a 
>> possibility to find out for every observation in which of the ten folds 
>> it is lying? I want to use the same folds for validating another 
>> regression method (moving averages) in order to choose the better one.
>>
>> Thanks a lot,
>> Pedro


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list