cvsegments(N, k, length.seg = ceiling(N/k),
type = c("random", "consecutive", "interleaved"))
"incomplete"
contains the number of incomplete
segments, and the attribute "type"
contains the type of segments.length.seg
is specified, it is used to calculate the number of
segments to generate. Otherwise k
must be specified. If
$k*length.seg \ne N$, the
$k*length.seg - N$ last segments will contain only
$length.seg - 1$ indices. If type
is "random", the indices are allocated to
segments in random order. If it is "consecutive", the first
segment will contain the first $length.seg$ indices, and so on.
If type
is "interleaved", the first segment will contain
the indices $1, length.seg+1, 2*lenght.seg+1, \ldots,
(k-1)*length.seg+1$, and so on.
## Segments for 10-fold randomised cross-validation:
cvsegments(100, 10)
## Segments with four objects, taken consecutive:
cvsegments(60, length.seg = 4, type = "cons")
## Incomplete segments
segs <- cvsegments(50, length.seg = 3)
attr(segs, "incomplete")
## Leave-one-out cross-validation:
cvsegments(100, 100)
## Leave-one-out with variable/unknown data set size n:
n <- 50
cvsegments(n, length.seg = 1)
Run the code above in your browser using DataLab