My question relates to the functions errorsarlm(), lagsarlm() and sacsarlm() of the "spdep" package. I would like to test the residuals of a regression created by one of the functions above on remaining spatial autocorrelation, for example by running a Moran's I test.
For linear models there exists the function lm.morantest() which tests for spatial autocorrelation among OLS residuals.
Is there a function already implemented in a package (not necessarily "spdep" or "spatialreg") that does this for the residuals of a spatial regression model? For example, would it be correct to do this by the moran.mc() command?
If no such function exists, what would be the correct approach to write such a function by myself?
Any help is much appreciated!
Yes, you can use Moran's I on the residuals:
ArcPro has a good write-up on using this diagnostic: