Hi all,

 

Many thanks to Roger for trying to replicate my problem with
nblag_cumul! You are correct in assuming that I am working with a GISCO
map on multiple levels, i.e. a combination of Nuts 1 and Nuts 2 regions.
However, the regions are distinct and not overlapping, so I presumed
that this should not constitute a problem. You can inspect my regional
classification in the directory where I stored my shapefile:

 

ftp://ftp.uibk.ac.at/private/c43227_20101117_a7cbdd66
<ftp://ftp.uibk.ac.at/private/c43227_20101117_a7cbdd66> 

 

Quick reminder: My problem lies in creating a second order queen matrix
with nblag_cumul when one region does not have any second order regions
and nblag_cumul produces a row of zeros for all first order neighbors of
this region. I was able to circumvent the problem by computing the path
matrix (multiplication of first order queen with itself) and merging the
two matrices making sure that the diagonal consists of zeros and all
second order neighbors are indicated with ones. That should do the
trick, my whole code is the following:

 

# Construction of second ord. queen mat with nblag (nb2listw command
fails because of empty neighbor set)

 

shapef <- readShapeSpatial("Europe_N1_N2")

queen.nb <- poly2nb(shapef)

second.order.lag <- nblag(queen.nb, 2)

queen2.nb <- nblag_cumul(second.order.lag)

queen2.lw <- nb2listw(queen2.nb, style ="W")

 

# Alternative solution based on path matrix

 

queen.mat <- nb2mat(queen.nb, style = "B")

queen2.temp1 <- queen.mat %*% queen.mat

vec.queen2 <- diag(queen2.temp1)

diag.queen2 <- diag(vec.queen2)

queen2.temp2 <- queen.mat + queen2.temp1

queen2.temp3 <- queen2.temp2 - diag.queen2

queen2.temp4 <- as.numeric(queen2.temp3 != 0)

queen2.mat <- matrix(data = queen2.temp4, nrow = 118, ncol = 118)

queen2.rs.mat <- solve(diag(rowSums(queen2.mat)))%*% queen2.mat

queen2.lw <- mat2listw(queen2.rs.mat)

 

In addition, another problem has surfaced when computing centroids. I
presume that centroids for the polygons in my dataset can be computed
with the coordinates() command in R:

 

# computation centroids

 

coord <- coordinates(shapef)

coord

 

For a comparison I also computed the centroids in ArcGis (generation of
x and y columns in the attribute table, right click on x and y,
calculate geometry, property: x/y coordinate of centroid). These
coordinates are indicated in the shapefile and in the excel output file
of the attribute table (also stored in the zip file). In this output
file the values for x/y coordinates of ArcGis and R centroids are
compared. Most are pretty much identical, for a few there are some
discrepancies (of up to 60 km). My questions now are the following:

 

*         Presuming my alternative solution for the second order queen
is correct, is there a more efficient way to compute this matrix (maybe
based on nblag)?

*         What could be a possible explanation for the discrepancies in
the computation of regional centroids for ArcGis and R?

 

Sorry for this lengthy post, any suggestions and explanations would be
greatly appreciated!

 

Best regards,

 

Christoph

 

 

Dr. Christoph Hauser

University of Innsbruck

Department of Economic s

Universitaetsstrasse 15

6020 Innsbruck

Tel.: 0043 512 507 7354

Fax: 0043 512 507 2980

 


	[[alternative HTML version deleted]]

