[R-sig-Geo] Problem with lm.morantest

buczkowski at delta.sggw.waw.pl buczkowski at delta.sggw.waw.pl
Sat Dec 25 14:05:07 CET 2004


Hello

I have a map of polygons in shapefile and a database in Access with
several 
attributes of the polygons from the shapefile. On data from the database I

am doing linear regression using function lm(). I would like to check 
whether there is spatial correlation in regresssion residuals. I loaded 
polygons using maptools, created a neighbor list using poly2nb() and then

spatial weights using nb2listw(). I made regression on data from the 
database (not from shapefile) and wanted to use lm.morantest() to
calculate 
Moran's I, and there the following error appeared "Error in 
lm.morantest(wmoddef, def_w, zero.policy = TRUE, alternative = "greater", 
:
        objects of different length" )

I realize that this is because the lists of polygons from shapefile and
records from regression are different. I was trying to match them by
sorting them in the same order but it didn't work. My question is how can
I conduct my analysis so the neighbor list and residuals from regression
would match each other in lm.morantest? 

Thanks in advance for your help

With best Christmas and New Year wishes

Rafal Buczkowski




More information about the R-sig-Geo mailing list