twofold_blocked_cross_validation
twofold_blocked_cross_validation.Rd
Construct a cross-validation specification that randomly partitions the input set into two sets of blocks.
Value
An object of class "twofold_blocked_cross_validation", "cross_validation", and "list" containing the block_var, nfolds (fixed at 2 for this function), nreps, and block_ind.
Details
This function creates a cross-validation scheme for cases where data is organized into blocks, and these blocks are divided into two groups for evaluation. This approach can be useful when there is an inherent structure or dependency within the blocks, and separating them can help to avoid biased estimates of model performance. It returns an object of class "twofold_blocked_cross_validation", "cross_validation", and "list".
Examples
blockvar <- rep(1:5, each=10)
nreps <- 5
cval <- twofold_blocked_cross_validation(blockvar, nreps=nreps)
samples <- crossval_samples(cval, as.data.frame(matrix(rnorm(50*50),50,50)), y=rep(letters[1:5],10))
#> Error in UseMethod("crossval_samples"): no applicable method for 'crossval_samples' applied to an object of class "c('twofold_blocked_cross_validation', 'cross_validation', 'list')"
stopifnot(nrow(samples) == nreps)
#> Error: object 'samples' not found