cv.tree(object, rand, FUN = shrink.tree, ..., big = F)
tree
.
This is assumed to be the result of some function that produces
an object with the same named
components as that returned by the
tree()
function.
tree
.
All elements of
rand
are in set 1:K for K-fold cross-validation.
An entry of 5, say, in the first position indicates that the first
observation will be in the test set in the
5th cross-validated replicate and in the training set for all K-1
remaining replicates.
If
rand
is missing, random 10-fold cross-validation is performed.
tree.sequence
.
Currently,
prune.tree
and
shrink.tree
are the only
such functions available.
FUN
, in particular the argument
k
, the
cost-complexity parameter if
FUN
is
prune.tree
or the shrinkage
parameter if
FUN
is
shrink.tree
. See these functions for details
on the use of
k
.
big
is
TRUE
,
object
is attached in
frame = 1
before
deviance
is calculated and detached before the value is returned.
tree.sequence
is returned.
The object contains the following components:
A
plot
method exists for objects of this class.
It displays the value of the deviance for each tree in the sequence.
An additional axis displays the values of the sequencing parameter
for each tree.
Chambers, J.M., and Hastie, T.J. (1991). Statistical Models in S, pp. 393--395 and 409--410
z.auto <- tree(Mileage ~ Weight, car.test.frame) zcv <- cv.tree(z.auto, k=(1:9)/10) plot(zcv)