# Spatial regression

I have a question regarding performing spatial regression on data which residuals are spatially correlated.

1. If the residuals are spatially autocorrelated due to the presence of trend, how should I account for the existence of spatial autocorrelation?

2. And what about if there is no trend, but rather spatial autocorrelation in random variation (in residuals left after detrending)?

3. And what about if there are both trend and spatially autocorrelated random variation in my data?

4. Can I in both cases apply this formula to account for spatial autocorrelation no matter if it is the result of trend or random variation correlation:

``````y^*=y-ρ∑(w_ij*y_j)
x^*=x-ρ∑_(w_ij*x_j)
``````

Thanks.

• In the formulas, what is rho? What is the relationship between the weights "w_ij" and the regression? What happened to the i subscripts on the left hand sides? Commented Jul 2, 2012 at 18:42
• Whuber, thank you for taking your time to read my question. Rho is the strength of correlation, and W_ij are weights applied to the values of y and x variables (depicting the influence of neighbouring values of variables at a certain location). This modified x and y variables (x* and y*) that are actually accounted for spatial autocorrelation will be then used in linear regression equation. I am not sure what values for weights to choose in case i have autocorrelation due to 1) or 2) or in case autocorrelation is due to both trend and correlation in random variation.
– Beka
Commented Jul 3, 2012 at 2:09

## 1 Answer

1. Include spatial coordinates (and if necessary, polynomial terms in them) as covariates in a regression.

2. Use geostatistical methods based on an underlying spatial stochastic process, such as a spatial generalized linear model as described in Diggle and Ribeiro Jr., Model-based Geostatistics (Springer 2007) and implemented in the `geoR` and `geoRglm` packages for `R`.

3. The best solution is to combine #1 and #2 simultaneously in one model. For some work, you can first apply #1 to remove trends and then apply #2 to the residuals. This is not quite correct because the regression likely did not account correctly for the correlation structure of the residuals. You can iterate, though: return to step 1 and use a weighted least squares (or appropriately weighted maximum likelihood) estimator and redo step 2. Repeat until the results converge, which they usually do within one to two iterations.

4. I cannot think of any circumstance in which such a formula would be valid. There definitely is no simple universal formula to account for spatial autocorrelation in regression settings.

• Whuber, thank you a lot for your answer. I have a question regarding including coordinates as covariates. If I expect the trend to be quadratic, and thus I include x squared and y squared in the regression model, but then x squared and y are excluded due to p-values that are higher than 0.05, how then should I interpret the existing trend? So, basically, x and y squared are only kept in the linear regression, as having p-values less than 0.05.
– Beka
Commented Jul 4, 2012 at 0:18
• After detrending the data in this way, I plan to use spatial lag regression (I think that method is also called autoregressive?) and thus in covariates include spatial effects that might exists in random variation. Based on the semivariogram I will make the decision on weighting. I hope my spatial regression designed this way will work well? Thank you once again for your help!
– Beka
Commented Jul 4, 2012 at 0:24
• Beka, For the quadratic regression you must also include an xy term along with x^2 and y^2. It's not necessary to eliminate terms according to a p-value threshold of 0.05; it depends on the purpose of the analysis, on what you know (or are willing to assume) about the trend beforehand, and on balancing the costs of overfitting against the costs of imprecision in the model. These are general issues in all statistical modeling: you can find extensive discussions of them on our sister site stats.stackexchange.com. Commented Jul 4, 2012 at 17:58