Hi, more of a general question rather than code help, but I have a dataset with response values of 0, 1 or 2 which has multiple observations per site. When calculating spatial autocorrelation via Moran's Index, should I take a mean average response value per site? As in, do the locations have to have unique x,y coordinates for the calculation to be valid, rather than using my raw data which has varying numbers of repeat observations per site
I am testing for spatial autocorrelation both in my pure response variable, and also in the residuals of my model to see if any significant spatial structure remains after accounting for my model effects, as spatial autocorrelation in the model residuals would indicate points are still not independent - again, should I be taking a mean of the residuals grouped by site to do this rather than all individual repeat points?
I had been doing this on my original response variable and actual residuals from my model using the Moran's I test from the ape package, and plotting correlograms for how MI changes by distance with the ncf package.
When using simulated residuals via DHARMa, I get the following error if trying to use all the individual points: Testing for spatial autocorrelation requires unique x,y values - if you have several observations per location, either use the recalculateResiduals function to aggregate residuals per location, or extract the residuals from the fitted object, and plot / test each of them independently for spatially repeated subgroups (a typical scenario would repeated spatial observation, in which case one could plot / test each time step separately for temporal autocorrelation).
Which suggests I have to group them by site for DHARMa's Moran's I test to work - not sure how recalculateResiduals function does it but they aren't means per site. So also, should I be using simulated residuals or actual residuals?
Thanks for any help