cvFolds {cvTools} | R Documentation |
Split n observations into K groups to be used for (repeated) K-fold cross-validation. K should thereby be chosen such that all groups are of approximately equal size.
cvFolds(n, K = 5, R = 1, type = c("random", "consecutive", "interleaved"))
n |
an integer giving the number of observations to be split into groups. |
K |
an integer giving the number of groups into
which the observations should be split (the default is
five). Setting |
R |
an integer giving the number of replications for repeated K-fold cross-validation. This is ignored for for leave-one-out cross-validation and other non-random splits of the data. |
type |
a character string specifying the type of
folds to be generated. Possible values are
|
An object of class "cvFolds"
with the following
components:
n |
an integer giving the number of observations. |
K |
an integer giving the number of folds. |
R |
an integer giving the number of replications. |
subsets |
an integer matrix in which each column contains a permutation of the indices. |
which |
an integer vector giving the fold for each permuted observation. |
Andreas Alfons
set.seed(1234) # set seed for reproducibility cvFolds(20, K = 5, type = "random") cvFolds(20, K = 5, type = "consecutive") cvFolds(20, K = 5, type = "interleaved") cvFolds(20, K = 5, R = 10)