foldControl {perry}R Documentation

Control object for cross-validation folds

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

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

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


[Package perry version 0.3.1 Index]