Skip to contents

Extracts Moran's I test results for spatial autocorrelation in model residuals from models fitted with rf(), rf_repeat(), or rf_spatial().

Usage

get_moran(model)

Arguments

model

Model object from rf(), rf_repeat(), or rf_spatial().

Value

Data frame with Moran's I statistics at multiple distance thresholds. Columns include distance.threshold, moran.i (statistic), p.value, interpretation, and method.

Details

Moran's I tests for spatial autocorrelation in model residuals. Significant positive values indicate residuals are spatially clustered, suggesting the model hasn't fully captured spatial patterns. For spatial models (rf_spatial()), low or non-significant Moran's I values indicate successful removal of spatial autocorrelation.

Examples

data(plants_rf)

# Extract Moran's I test results
moran_results <- get_moran(plants_rf)
moran_results
#>   distance.threshold     moran.i moran.i.null      p.value
#> 1                100 0.163544964 -0.004424779 6.854407e-08
#> 2               1000 0.072542848 -0.004424779 5.285324e-07
#> 3               2000 0.026479300 -0.004424779 2.115511e-03
#> 4               4000 0.007600359 -0.004424779 3.166076e-02
#>                 interpretation
#> 1 Positive spatial correlation
#> 2 Positive spatial correlation
#> 3 Positive spatial correlation
#> 4 Positive spatial correlation

# Check for significant spatial autocorrelation
significant <- moran_results[moran_results$p.value < 0.05, ]
significant
#>   distance.threshold     moran.i moran.i.null      p.value
#> 1                100 0.163544964 -0.004424779 6.854407e-08
#> 2               1000 0.072542848 -0.004424779 5.285324e-07
#> 3               2000 0.026479300 -0.004424779 2.115511e-03
#> 4               4000 0.007600359 -0.004424779 3.166076e-02
#>                 interpretation
#> 1 Positive spatial correlation
#> 2 Positive spatial correlation
#> 3 Positive spatial correlation
#> 4 Positive spatial correlation