Hi everyone,
I am trying to find a way to calculate an adjacency matrix from a polygon shapefile to make a CAR model in winbugs, but I would like to vary the order of neihborhood. I used the the spdep package to create an adjacency matrix (in list format) of order 2 and it works pretty fine: shape <- readShapePoly("path_to_my_shapefile", IDvar="Id") shape_nb<-poly2nb(shape) data<-list(N = length(shape_nb), num=sapply(shape_nb, length), adj=unlist(shape_nb), lst <- attr(shape_nb, "region.id"), adj2 <- lst[unlist(shape_nb)], sumNumNeigh=length(unlist(shape_nb)) is everyone know how to calculate an adjacency matrix in R for polygon shapefile but for higher orders of neihborhood (ex: 3,4,5, etc...)? I did not see any option for that with poly2nb() in spdep package but I imagine that other tools have to exist. Your help would be greatly appreciated. Best regards, Julien ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.