My apologies for the duplicate list, but I forgot to use plain text in my last post, and thus there was a problem posting to archive. Here is the post now:
Hi Everyone, I'm new to R, so thank you in advance for your patience. I'm using US census block groups in Buffalo New York to examine how neighborhood characteristics affect crime. I would like to use an inverse distance weights (distance decay) of block group centroids that is banded at 1 kilometer. In other words, I would like to create a one kilometer buffer around each of the centroids, then use row standardized inverse distance weights. Finally, I would like to run a spatial error model using these weights. Here is my code: > library(foreign) > library(spdep) > > buffalo <- read.dta("buffalo_blkgrps.dta") > attach(buffalo) > names(buffalo) [1] "bgidfp00" "gage2900" "gavghhinc00" "gblack00" "gcrwd00" [6] "gethhet00" "ghhincsdln00" "glatino00" "gocc00" "gowner00" [11] "gpop00" "gpov00" "assaul" "robber" "burglr" [16] "motveh" "murder" "larcen" "x" "y" > > #distance based neighbors - making a neighbor list - bounded to 1 kilometer > coords <-(cbind(x,y)) > neigh.nb <- dnearneigh(coords, 0, 1, longlat=TRUE) > summary(neigh.nb) Neighbour list object: Number of regions: 409 Number of nonzero links: 5298 Percentage nonzero weights: 3.167126 Average number of links: 12.95355 1 region with no links: 12 Link number distribution: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 1 3 3 4 5 14 25 28 23 19 26 32 44 29 24 29 25 24 13 15 12 3 4 1 1 1 1 least connected region: 3 with 1 link 1 most connected region: 382 with 26 links > > #making inverse distance weights > neigh.dist <- nbdists(neigh.nb, coords, longlat=TRUE) > inverse <- lapply(neigh.dist, function(x) (1/(x^2))) > > #creating row standardized spatial weights from list > neigh.listw <- nb2listw(inverse, style="W",zero.policy=TRUE) Error in nb2listw(inverse, style = "W", zero.policy = TRUE) : Not a neighbours list > traceback() 2: stop("Not a neighbours list") 1: nb2listw(inverse, style = "W", zero.policy = TRUE) > > > assault <- errorsarlm(assaul_r ~ gage2900 + gblack00 + gcrwd00 + gethhet00 + > ghhincsdln00 + glatino00 + gocc00+ gowner00 + gpov00, + data=buffalo,listw=neigh.listw, zero.policy=TRUE) Error in eval(expr, envir, enclos) : object 'assaul_r' not found The model will run when I do not include the code with the inverse weights and only interpoint distances, but it's unclear to me why I can't include the inverse distances when using nb2listw. Any ideas on why this is occurring and/or help to alleviate this issue would be much appreciated. The spatial error model from errorsarlm (package=spdep) will also run fine when I don't include the inverse weights. Is there a better way to go about running this spatial error model using row standardized inverse distance weights? Would spautolm from the spdep package be better suited for these data? Any comments or suggestions are welcome. Thank you for your time! Adam Adam Boessen Doctoral Student Department of Criminology, Law and Society University of California, Irvine aboes...@uci.edu p.s. If it's helpful, here is my version of R: > version _ platform i386-apple-darwin9.8.0 arch i386 os darwin9.8.0 system i386, darwin9.8.0 status major 2 minor 10.1 year 2009 month 12 day 14 svn rev 50720 language R version.string R version 2.10.1 (2009-12-14) _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo