After fitting a model, checks whether residuals still exhibit spatial autocorrelation. If they do, the model has not fully captured the spatial process and predictions may be biased.
Arguments
- model
A fitted model with a
residuals()method, or a numeric vector of residuals.- data
Data frame with coordinate columns (needed if
modelis a numeric vector).- coords
Character vector of length 2. Coordinate column names.
- alpha
Numeric. Significance level for Moran's I test. Default: 0.05.
- crs
Optional coordinate reference system (an
sfCRS, EPSG code, or PROJ string). When geographic (lon/lat), distances use the Haversine formula; otherwise planar Euclidean.
Value
A list with class "borg_residual_check" containing:
- morans_i
Moran's I of residuals
- p_value
P-value from Moran's I test
- significant
Logical. Whether residual autocorrelation is significant
- variogram
Residual variogram data frame (if computed)
- assessment
Character. "clean", "mild", or "strong"
Has an autoplot() method showing the residual variogram.