[R-sig-Geo] dnearneigh, knearneigh and SAR - not removing spatial autocorrelation

Roger Bivand Roger.Bivand at nhh.no
Wed Apr 27 22:16:13 CEST 2011


On Wed, 27 Apr 2011, Chris Mcowen wrote:

> Dear list,
>
> I was wondering if somebody could possibly offer me some advice?
>
> I have a dataset where there is spatial autocorrelation present - 
> visible from the correlogram. So i tried to remove it using a SAR. My 
> data is for 458 regions of differing size for which i have long - lat 
> co-ordinates.
>
>
> coords<-cbind(data$X,data$Y)
> coords<-as.matrix(coords)
>
> The first approach was to use dnearneigh to set up the neighbourhood. I 
> am very new to this and was having problems as regions would often 
> appear with no links ( see below) so i upped dmax until this no longer 
> occurred - this maybe a incorrect method?
>
>> dnearneigh(coords, 0, 1500, row.names = NULL, longlat = TRUE)
> Neighbour list object:
> Number of regions: 458
> Number of nonzero links: 8990
> Percentage nonzero weights: 4.285769
> Average number of links: 19.62882
> 2 regions with no links:
> 235 236
>
> Results in - Empty neighbour sets found
>
>> dnearneigh(coords, 0, 2000, row.names = NULL, longlat = TRUE)
> Neighbour list object:
> Number of regions: 458
> Number of nonzero links: 14200
> Percentage nonzero weights: 6.769512
> Average number of links: 31.00437
>
> I then converted this to a weight matrix and used in my SAR.
>
> nb1.5 <- dnearneigh(coords, 0, 2000, row.names = NULL, longlat = TRUE)
> nb1.5.w<-nb2listw(nb1.5, glist=NULL, style="W", zero.policy=FALSE)
>
> However, looking at the correlogram and the AIC ( below) it seems to not 
> have made a huge difference
>
> AIC: -2581.8, (AIC for lm: -2574)

With relatively large numbers of neighbours, you smooth more. What 
definition of neighbour are you using in the correlogram? Why not just use 
the same? The correlogram obviously doesn't care about no-neighbour 
observations, so perhaps do the same? If you want to link every 
observation in, why not then down-weight distant neighbours using inverse 
distance weights - see ?nbdists.

The test neighbour definition and the weights used for model fitting do 
not match. Further, you don't say whether your correlogram is for the OLS 
model residuals or just the response variable. If the latter, the 
explanatory variables may co-vary in space with the response, so the 
residuals are in fact not spatially autocorrelated.

Hope this helps,

Roger

>
> So i tried defining my neighbourhood using the knearneigh function but that made very little difference
>
> test <- knearneigh(coords, k=1, longlat = NULL, RANN=TRUE)
> knn2nb(test, row.names = NULL, sym = FALSE)
> k1 <- knn2nb(knearneigh(coords))
> all.linked <- max(unlist(nbdists(k1, coords)))
> col.nb.0.all <- dnearneigh(coords, 0, all.linked, row.names=rn)
>
> AIC: -2581.8, (AIC for lm: -2574)
>
> IS there something i am doing wrong or is there a step i am not doing?
>
> Any help would be gratefully received.
>
> Chris
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list