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

Chris Mcowen chrismcowen at gmail.com
Wed Apr 27 21:34:45 CEST 2011


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)

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



More information about the R-sig-Geo mailing list