generate_cv_folds | R Documentation |
Creates cross-validation fold assignments for presence-absence or presence-only data, supporting three types of strategies: k-fold, spatial blocks (through blockCV R package), and temporal blocks.
generate_cv_folds(
data,
method = "k-fold",
block_method = "predictors_autocorrelation",
block_size = NULL,
k = 10,
predictor_raster = NULL,
model_residuals = NULL,
coords = c("decimalLongitude", "decimalLatitude")
)
data |
A 'data.frame' with at least presence-absence data ('pa'), coordinates, and optionally a 'timestamp'. |
method |
The cross-validation strategy. One of: '"k-fold"', '"spatial_blocks"', '"temporal_blocks"'. |
block_method |
For spatial blocks, how to determine block size. One of: '"residuals_autocorrelation"', '"predictors_autocorrelation"', '"manual"'. |
block_size |
Numeric. Manual block size in meters (used if 'block_method = "manual"'). |
k |
Integer. Number of folds to generate. |
predictor_raster |
A 'terra::SpatRaster' used for estimating spatial autocorrelation (only needed if 'block_method = "predictors_autocorrelation"'). |
model_residuals |
A 'data.frame' with residuals and coordinates (only needed if 'block_method = "residuals_autocorrelation"'). |
coords |
A character vector of length 2 indicating the longitude and latitude column names. |
A list with the following elements:
A vector of fold assignments (one per row in 'data').
The CV method used.
The spatial block size method (if applicable).
The estimated or manual block size (in meters), if spatial blocks were used.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.