Correct way to incorporate spatial autocorrelation

Hey @daniel_yao

I can’t tell from the sample data what the grid layout is like. How you proceed will depend on the layout, whether its a regularly spaced grid (Like a square tessellation) or you have irregularly placed plots, all with potentially different distances between neighbors.

Of the options you’re looking at here, stick with the cor_car specification for the autocorrelation and I suggest staying away from (1|gr(grid_no, cov = dist) with spatial data. It would probably get stopped at peer review (assuming someone with a spatial stats background reviews it).

Here’s a note from the brms documentation for the cor_car function (hopefully not out of date):

W Adjacency matrix of locations. All non-zero entries are treated as if the two locations are adjacent.

The model is considering these locations as neighbors (1s) or not-neighbors (0s). That may or may not be good enough for your data.

Doesn’t this mean the entire matrix is getting converted to 1s, given you’ve passed in distances? If you want to use this model you’ll have to create the connectivity matrix some other way. E.g. use the lon-lat columns to create an sf or spatialpoints class r - How to Convert data frame to spatial coordinates - Stack Overflow and then use spdep to make a spatial weights matrix based on nearest neighbors maybe.

CAR, ICAR, and eigenvector spatial filtering models can incorporate non-binary weights like distances but there hasn’t been a lot of work on that in Stan yet to my knowledge (but this looks promising Sampling and identifiability of a spatial model with second-order IGMRF prior )