KfoldCV: Split a dataset into k parts for k-fold cross-validation

Description Usage Arguments Value Author(s) Examples

View source: R/pact.R

Description

Split a dataset into k parts for k-fold cross-validation. This function is used in pact.cv to create the splits for cross-validation

Usage

1
KfoldCV(n, k)

Arguments

n

The sample size

k

The number of folds. k=n would mean a leave-one-out cross-validation

Value

A integer vector of same length as n. Each observation is an integer taking a value between 1 to k denoting the fold it belongs to.

Author(s)

Jyothi Subramanian and Richard Simon
Maintainer: Jyothi Subramanian <[email protected]>

Examples

1
2
KfoldCV(15,3)
KfoldCV(15,15)

Example output

 [1] 1 1 1 1 2 3 2 2 2 3 3 3 1 3 2
 [1] 14  5  3  7  4  6 13  2  1 10 15  9 12 11  8

pact documentation built on May 29, 2017, 3:12 p.m.