Skip to content

Generates a spatially aware data split using the spatialsample package. This helps avoid inflated model performance estimates due to spatial autocorrelation.

Usage

h3sdm_spatial_cv(data, method = "block", v = 5, ...)

Arguments

data

An sf object, typically the output of h3sdm_data().

method

Character. The spatial resampling method to use:

"block"

Use spatial_block_cv for block-based spatial CV.

"cluster"

Use spatial_cluster_cv for cluster-based spatial CV.

v

Integer. Number of folds (default = 5).

...

Additional arguments passed to the underlying spatialsample function.

Value

An rsplit object (from rsample) representing the spatial CV folds.

Examples

if (FALSE) { # \dontrun{
# Block spatial cross-validation
spatial_cv_block <- h3sdm_spatial_cv(combined_data, method = "block")

# Cluster spatial cross-validation with 10 folds
spatial_cv_cluster <- h3sdm_spatial_cv(combined_data, method = "cluster", v = 10)
} # }