datasplit {spm2} | R Documentation |
Split data for k-fold cross-validation
Description
This function is a data splitting function for k-fold cross- validation and uses a stratified random sampling technique. It resamples the training data based on sample quantiles.
Usage
datasplit(trainy, k.fold = 10)
Arguments
trainy |
a vector of response, must have a length equal to sample size. |
k.fold |
integer; number of folds in the cross-validation. if > 1, then apply k-fold cross validation; the default is 10, i.e., 10-fold cross validation that is recommended. |
Value
A list of samples each with an index of k-fold number.
Note
This function is largely based on rfcv in randomForest.
Author(s)
Jin Li
References
A. Liaw and M. Wiener (2002). Classification and Regression by randomForest. R News 2(3), 18-22.
Examples
library(spm)
data(petrel)
idx1 <- datasplit(petrel[, 3], k.fold = 10)
table(idx1)
[Package spm2 version 1.1.3 Index]