Spatial cross-validation with circular exclusion buffers around test points. For each fold, all training points within a specified radius of any test point are removed, creating a spatial gap that eliminates autocorrelation leakage. More principled than rectangular or k-means blocking for point data.
Usage
borg_disc_cv(
data,
coords,
target = NULL,
radius = NULL,
v = 5,
min_train = 0.5,
seed = 42,
output = c("list", "rsample"),
verbose = FALSE
)Arguments
- data
A data frame with coordinate and predictor columns.
- coords
Character vector of length 2. Coordinate column names.
- target
Character. Target variable name (for diagnostics).
- radius
Numeric. Exclusion buffer radius in coordinate units. If
NULL, automatically set to the autocorrelation range estimated byborg_diagnose().- v
Integer. Number of folds. Default: 5.
- min_train
Numeric. Minimum fraction of data that must remain in training after exclusion. Folds that violate this are dropped. Default: 0.5.
- seed
Integer. Random seed. Default: 42.
- output
Character. Output format:
"list"(default),"rsample".- verbose
Logical. Print diagnostic messages. Default: FALSE.
Value
A list with class "borg_disc_cv" containing:
- folds
List of train/test index vectors
- radius
Exclusion radius used
- n_excluded
Number of training points excluded per fold (in the buffer zone)
- effective_training
Fraction of data available for training per fold (after exclusion)
- strategy
"leave_disc_out"
- params
List of parameters used
Compatible with other BORG functions that accept fold lists.
Details
How it works
Partition data into
vspatial folds using k-means on coordinates (same asborg_cv).For each fold, identify the test points.
Remove from training all points within
radiusof any test point. These excluded points are neither train nor test — they form a buffer zone.If the remaining training set is too small (
< min_train * n), the fold is dropped with a warning.
Choosing the radius
The radius should match the autocorrelation range of the spatial
process. borg_diagnose() estimates this via variogram
analysis. Setting radius = NULL uses this estimate
automatically.