Dear All, My end goal is to run a spatial lag model, where the weight matrix will be nonsymmetric and contain observations with zero neighbors. I am having some difficulties in creating the neighbor list in R. Any advice or pointers on where to find more information would be greatly appreciated.
I needed to account for both time and space when defining a list of neighbors, and did so first using ArcInfo and then SAS, and saved the final list as a dbf. It seems I next want to convert this dbf into a neighbor list in R, and was told the best thing to do is save the dbf as a gwt file and change the header line. A brief portion is pasted below: 0 34451 nfred3 DGID 105450 105578 1 105451 105763 1 105451 105627 1 105451 105899 1 105451 105898 1 105451 105915 1 105452 105763 1 105452 105841 1 nfred3 is the name of the gwt file, and DGID is the unique id for each observation. There are a total of 34,451 unique observations, some of which do not have any neighbors and are thus not included in the above gwt file. If I run gwt2nb accounting for these zero link observations I get the following warning messages: > DGID<-sales$dgid > length(DGID) [1] 34451 > n2n<-read.gwt2nb("nfred3.gwt", region.id=DGID) Warning messages: 1: In read.gwt2nb("nfred3.gwt", region.id = DGID) : region.id not named DGID 2: In read.gwt2nb("nfred3.gwt", region.id = DGID) : 105462, 105463, 105466, 105468, 105472, ... [... truncated] 3: In read.gwt2nb("nfred3.gwt", region.id = DGID) : 105450, 105454, 105455, 105462, 105468, ... [... truncated] The issue is that there are a total of 1,555 regions with no links, but 1,090 of these regions should have a positive number of links . The truncated list in the warning message contains id numbers that should have zero links, as well as some that should have nonzero links. If I run similar code but only account for observations with nonzero links, then I have the correct number of nonzero links. So this neighbor list at first glance seems correct, but I still need to account for observations with zero links when later forming the weights, and I am concerned about the below warning messages. > #create vector of unique sale ids with nonzero spatial link (i.e. has > neighbors) > n2n0<-read.table("nfred4.gwt",header=FALSE,skip=1) > DGID<-unique(n2n0$V1) > length(DGID) [1] 33986 > n2n<-read.gwt2nb("nfred4.gwt", region.id=DGID) Warning messages: 1: In read.gwt2nb("nfred4.gwt", region.id = DGID) : region.id not named DGID 2: In read.gwt2nb("nfred4.gwt", region.id = DGID) : 105450, 105454, 105455, 105470, ... [... truncated] Any advice or pointers of where I can find some helpful info would be greatly appreciated. Thank you, Denny [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo