Generate spatio-temporal cross-validation index with spatialsample::spatial_block_cv
and year-based temporal folds
Source: R/base_learner.R
generate_cv_index_spt.Rd
This function generates spatio-temporal cross-validation indices with
v
spatial blocks and year-based temporal folds. The spatial blocks
are generated with spatialsample::spatial_block_cv
function, and the
temporal folds are generated based on the years availble in data$time
.
Total number of folds is equal to
v * length(unique(substr(data$time, 1, 4)))
.
Usage
generate_cv_index_spt(
data,
locs_id = "site_id",
coords = c("lon", "lat"),
v = 10L,
time_id = "time",
...
)
Arguments
- data
data.table or data.frame with
id
,coords
, andtime
columns.- locs_id
The column name in
data
that represents the location identifier.- coords
The column names in the spatial object that represent the XY coordinates. Default is
c("lon", "lat")
.- v
integer(1). The number of partitions for the resampling.
- time_id
The column name in
data
that represents the time values.- ...
Additional arguments to be passed to
spatialsample::spatial_block_cv
.