foldControl: Control object for cross-validation folds

Description Usage Arguments Value Author(s) See Also Examples

View source: R/perrySplits.R

Description

Generate an object that controls how to split n observations or groups of observations into K folds to be used for (repeated) K-fold cross-validation. K should thereby be chosen such that all folds are of approximately equal size.

Usage

1
2
3
4
5
6
foldControl(
  K = 5,
  R = 1,
  type = c("random", "consecutive", "interleaved"),
  grouping = NULL
)

Arguments

K

an integer giving the number of folds into which the observations should be split (the default is five).

R

an integer giving the number of replications for repeated K-fold cross-validation.

type

a character string specifying the type of folds to be generated. Possible values are "random" (the default), "consecutive" or "interleaved".

grouping

a factor specifying groups of observations.

Value

An object of class "foldControl" with the following components:

K

an integer giving the number of folds. A value of K equal to the number of observations or groups yields eave-one-out cross-validation.

R

an integer giving the number of replications. This will be 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.

grouping

if supplied, a factor specifying groups of observations. The data will then be split according to the groups rather than individual observations such that all observations within a group belong to the same fold.

Author(s)

Andreas Alfons

See Also

perrySplits, cvFolds, splitControl, bootControl

Examples

1
2
3
set.seed(1234)  # set seed for reproducibility
perrySplits(20, foldControl(K = 5))
perrySplits(20, foldControl(K = 5, R = 10))

perry documentation built on Nov. 3, 2021, 5:08 p.m.