# spatial autocorrelation for time series data

I have a 20-yr dataset of an annual count of species abundance for a set of polygons (~200 irregularly shaped, continuous polygons). I have been using regression analysis to infer trends (change in count per year) for each polygon, as well as aggregations of polygon data based on management boundaries.

I am sure that there is spatial autocorrelation in the data, which is sure to impact the regression analysis for the aggregated data. My question is - how do I run a SAC test for time series data? Do I need to look at the SAC of residuals from my regression for each year (global Moran's I)? Or can I run one test with all years?

Once I've tested that yes there is SAC, is there an easy was to address this? My stats background is minimal and everything I've read on spatio-temporal modeling sounds very complex. I know that R has a distance-weighted autocovariate function - is this at all simple to use?

I'm really quite confused on how to assess/addess SAC for this problem and would very much appreciate any suggestions, links, or references. Thanks in advance!

• Do you wish to model underlying spatial processes, or do you wish to adjust your variance-covariance matrix estimation to account for spatial autocorrelation? Apr 22 '13 at 23:53
• Or do you want to do both... Apr 22 '13 at 23:58
• Thanks for your answers! I think that my data does have spatial autodependence - it is biological and very likely that species counts in neighbouring units will impact surrounding units. My units are fairly large, so I intend to just use the 'connecting on edges and corners' option to set the distance lag to test SAC. The R functions for the SAC models look do-able (still over my head!). Thanks again. Apr 23 '13 at 13:45
• Welcome to the site Rozza, this should be left as a comment to one of the answers. Although be sure to upvote the existing answers if they provided helpful responses, and mark one of them as answering your question if you feel it has been satisfactorily addressed. Apr 23 '13 at 14:09

According to this paper, OLS is consistent in the presence of spatial autocorrelation, but standard errors are incorrect and need to be adjusted. Solomon Hsiang provides stata and matlab code for doing so. Unfortunately I'm not familiar with any R code for this.

There are certainly other approaches to this sort of problem in spatial statistics that explicitly model spatial processes. This one just inflates the standard errors.

Theoretical econometricians unfortunately seem to take pleasure in obfuscating. The linked paper is really hard to read. Basically what it says is run whatever regression you want, and then go fix the standard errors later. Space doesn't come into it until you try to estimate the variance of your estimator. Intuitively, if all the difference is close together, you're less certain that your estimate isn't just a relic of some unobserved spatial shock.

Note that you need to specify a kernel bandwidth over which you think the spatial process might be operating.

If the issue is autocorrelated errors, $y = X\beta + u, u=\rho Wu + \epsilon$, then OLS is consistent but inefficient, as ACD says. It's like serial correlation in time series econometrics.
But if there is spatial autodependence (also called autocorrelation, confusingly), $y = \rho W y+ X\beta + \epsilon$, then OLS is inconsistent. It's the same thing as a missing variable bias. If you have both issues, you need to use the Spatial Durbin Model, $y = \rho W y + X\beta + WX \lambda + \epsilon$.
The spdep package for R contains numerous functions that compute spatial weights matrices, estimate spatial regressions, and do other things. I have a good deal of experience with the lagsarlm functions, but see in the package documentation that there is a sacsarlm function that seems to be more of what you are looking for.
As far as the temporal aspect of your problem, the assumptions you make on dependence will go a long way to determining your model specification. Do your areas interact with each other directly? Examples of this are trade or housing markets; the exports from one country are highly dependent on the imports in another, and the sale price of recently bought houses is a very important contribution to the sale price of nearby houses. In this case, it makes sense to specify your weights matrix $W$ to accommodate this dependence. Allow a house purchased in time $t$ to be "neighbors" with houses in time $t-1$, but not with houses in time $t +1$.
If your terms are correlated but not logically dependent on each other, such as agricultural yields, it would probably make more sense to have a single time-insensitive matrix $W$, but to include year dummies in the $X$ specification.