Computes permutation importance that respects spatial structure. Instead of permuting individual rows (which breaks spatial autocorrelation and inflates importance), permutes values within spatial blocks.
Usage
borg_importance(
model,
data,
target,
coords = NULL,
predictors = NULL,
n_blocks = 10,
n_rep = 10,
metric = c("rmse", "mae"),
seed = 42
)Arguments
- model
A fitted model with a
predict()method.- data
Data frame with predictor columns.
- target
Character. Target variable name.
- coords
Character vector of length 2. Coordinate column names. If
NULL, falls back to standard row permutation.- predictors
Character vector. Variables to assess. If
NULL, uses all columns except target and coords.- n_blocks
Integer. Number of spatial blocks for permutation. Default: 10.
- n_rep
Integer. Number of permutation repeats per variable. Default: 10.
- metric
Character.
"rmse"(default) or"mae".- seed
Integer. Random seed. Default: 42.