I have a dataset of observations at multiple sites repeated within and at multiple times. I need to test for spatial autocorrelation in the residuals of my model, which I have used time as a fixed effect for.

Do I use means per site of my actual residuals extracted from the model for a Moran's Index test by the `ape`

package, or should I use simulated residuals calculated by the `recalculateResiduals`

function from `DHARMa`

(since the individual points don't have unique x,y values)? Any examples I've seen have used `DHARMa`

, but basically I'm not sure why you would use simulated residuals instead of actual residuals? Thanks.

# Modeling – Actual Residuals vs. Simulated Residuals for Testing Spatial Autocorrelation

autocorrelationmodelingresidualsspatial

## Best Answer

Note that I'm the developer of DHARMa, so my opinions may be biased from that, but here is my view:

The problem with autocorrelation tests on raw residuals arises when you have a model where the expected variance (and may be also the distribution) is (spatially) inhomogeneous. Imagine e.g. if you have a Poisson regression, and in one area of the space you have low mean incidence, and in another area high. Then it can appear visually as if the low area is spatially autocorrelated. The DHARMa simulations re-scale residuals before performing further tests, so that you would have a homogenous pattern (assuming that there is no true autocorrelation in the model).

So, basically, DHARMa should improve things for all models that where variance of distributional shape change spatially, which includes many GL(M)Ms. For simple LMMs, you'll be fine with tests on raw / Pearson residuals.