Learn R Programming

CVThresh (version 1.1.0)

cvtype: Generating test dataset index for cross-validation

Description

This function generates test dataset index for cross-validation.

Usage

cvtype(n, cv.bsize=1, cv.kfold, cv.random=TRUE)

Arguments

n
the number of observation
cv.bsize
block size of cross-validation
cv.kfold
the number of fold of cross-validation
cv.random
whether or not random cross-validation scheme should be used. Set cv.random=TRUE for random cross-validation scheme

Value

  • matrix of which row is test dataset index for cross-validation.

Details

This function provides index of test dataset according to various cross-validation scheme. One may construct K test datasets in a way that each testset consists of blocks of b consecutive data. Set cv.bsize = b for this. To select each fold at random, set cv.random = TRUE.

See Also

cvwavelet, cvimpute.by.wavelet, cvwavelet.after.impute.

Examples

Run this code
# Traditional 4-fold cross-validation for 100 observations
cvtype(n=100, cv.bsize=1, cv.kfold=4, cv.random=FALSE)
# Random 4-fold cross-validation with block size 2 for 100 observations
cvtype(n=100, cv.bsize=2, cv.kfold=4, cv.random=TRUE)

Run the code above in your browser using DataLab