Generate temporal cross-validation index
Arguments
- data
data.table with X, Y, and time information.
- time_col
character(1). Field name with time information.
- cv_fold
integer(1). Number of cross-validation folds.
- window
integer(1). Window size for each fold. Simply meaning overlaps between folds. Unit is the base unit of temporal values stored in
time_col
. Window size is put intoas.difftime
function, then the half of it (if odd, rounded number + 1 is applied) is used for overlaps in the middle folds.
Examples
data <- data.frame(
time = seq.Date(from = as.Date("2021-01-01"), by = "day", length.out = 100),
value = rnorm(100)
)
rset_ts <-
generate_cv_index_ts(data, time_col = "time", cv_fold = 10, window = 14)