[R-sig-Geo] Regression analysis: how to convert shapefiles to listw-objects?

Anja Matatko Anja.Matatko at alta4.com
Tue May 2 13:19:36 CEST 2006


Roger and list, 

thanks for your help with importing my shapefiles. 

As I don't want to use only the lm() command for regression analysis but
also more complex ones as lm.morantest() and others, it seems that I
need a listw-object instead of my shapefile. 

What I think I should do is:
- create polylist or Spatial Polygons
- use poly2nb()
- use nb2listw ()

My results: 
> abo_object_neu <- readShapePoly ("abo_poly",
proj4string=CRS(as.character (NA)), verbose=FALSE)
> summary(abo_object_neu)
Object of class SpatialPolygonsDataFrame
Coordinates:
       min     max
r1 2508089 2644341
r2 5442170 5640160
Is projected: NA 
proj4string : [NA]
Data attributes: (several attributes, I deleted them here)


I thought "SpatialPolygonsDataFrame" should be one of these
"SpatialPolygon"-objects to serve as input for poly2nb, but trying this
function, the answer was: 

> abo_nb <- poly2nb(abo_object_neu, row.names=NULL,
snap=sqrt(.Machine$double.eps), queen=TRUE)
Error in poly2nb(abo_object_neu, row.names = NULL, snap =
sqrt(.Machine$double.eps),  : 
        Not a polygon list


My question: what is going wrong, are there other functions to do this
conversion from shapefile to listw-object? Is there a direct shapefile
to listw-conversion-function? I really tried to find it in help files,
but had no success. 

Thanks, Anja

> sessionInfo()
Version 2.3.0 (2006-04-24) 
i386-pc-mingw32 

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"
"datasets"  "base"     

other attached packages:
   spdep     boot  SparseM maptools       sp  foreign  tripack       PK 
"0.3-22" "1.2-24"   "0.68" "0.5-11" "0.8-14" "0.8-15" "1.2-10"   "0.03"




More information about the R-sig-Geo mailing list