[R] using xval in mvpart to specify cross validation groups
Andrew Dolman
andydolman at gmail.com
Fri Mar 12 13:15:02 CET 2010
Dear R's
I'm trying to use specific rather than random cross-validation groups
in mvpart.
The man page says:
xval Number of cross-validations or vector defining cross-validation groups.
And I found this reply to the list by Terry Therneau from 2006
The rpart function allows one to give the cross-validation groups explicitly.
So if the number of observations was 10, you could use
> rpart( y ~ x1 + x2, data=mydata, xval=c(1,1,2,2,3,3,1,3,2,1))
which causes observations 1,2,7, and 10 to be left out of the first xval
sample, 3,4, and 9 out of the second, etc.
Terry Therneau
I can't see how this string of values, c(1,1,2,2,3,3,1,3,2,1), codes
for observations 1,2,7,10 being left out of the 1st and so on.
Can anyone fill me in please?
Thanks,
andydolman at gmail.com
More information about the R-help
mailing list