createCVgroups {predkmeans}R Documentation

Creating k-fold Cross-Validation Groups

Description

Splits a vector of observation names or indices into a list of k groups, to be used as cross-validation (CV) test groups.

Usage

createCVgroups(x = NULL, n = length(x), k = 10, useNames = TRUE)

Arguments

x

vector of observation ID's (character or numeric) to split into cv groups.

n

number of observations to split into cv groups. Defaults to the length of x, but can also be provided instead of x.

k

number of cross-validation groups. Must be less than or equal to n.

useNames

logical indicator of whether the names of 'x' should be used to identify observations within cv groups.

Value

A list of length k giving the IDs of observations within each test group.

Author(s)

Joshua Keller

See Also

predkmeansCVest predkmeansCVpred

Examples

# 5-fold groups
cv5 <- createCVgroups(n=100, k=5)
cv5

# Leave-one-out
cvLOO <- createCVgroups(n=100, k=0)
cvLOO

[Package predkmeans version 0.1.1 Index]