Cross-validation indices with a buffer between training/validation datasets

Description

Caculates training/validation indices for N-fold cross-validation of a dataset. Cross-validation folds are taken as contiguous blocks of cases with an optional buffer to prevent leakage of information between training/validation subsets due to the presence of autocorrelation.

Usage

1
xval.buffer(n.cases, n.xval=5, buffer.length=0)

Arguments

n.cases

an integer specifying the length of the dataset.

n.xval

an integer specifying the desired number of cross-validation folds.

buffer.length

an integer specifying the number of cases to be left out as a buffer between the training/validation subsets.

Value

a list with n.xval elements, each containing:

train

indices of training cases

valid

indices of validation cases

References

Shabbar, A. and V. Kharin. 2007. An assessment of cross-validation for estimating skill of empirical seasonal forecasts using a global coupled model simulation. CLIVAR Exchanges. 12(4): 10-12.

Zeng, Z., W.W. Hsieh, A. Shabbar, and W.W. Burrows, 2011. Seasonal prediction of winter extreme precipitation over Canada by support vector regression, Hydrology and Earth System Sciences, 15: 65-74.

Examples

1
  print(xval.buffer(100, n.xval = 3, buffer.length = 10))