[R-sig-Geo] RE : Adjacency matrix of higher order (from winbugs to R)
Julien Beguin
julien.beguin.1 at ulaval.ca
Mon Mar 8 18:35:52 CET 2010
Thank you Roger, problem resolved.
Julien
________________________________________
De : Roger Bivand [Roger.Bivand at nhh.no]
Date d'envoi : 5 mars 2010 09:06
À : Julien Beguin
Cc : r-sig-geo at stat.math.ethz.ch
Objet : Re: [R-sig-Geo] Adjacency matrix of higher order (from winbugs to R)
On Thu, 4 Mar 2010, Julien Beguin wrote:
> 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 checked previous messages on the list but did not find
> this specific topic. I used the the spdep package to create an adjacency
> matrix (in list format) of order 2 and it works pretty fine:
Did you look at ?nblag - is that what you need?
Roger
> ---------------------------------------------------------------------------
> ------------
> 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 with the function poly2nb() in spdep package but I
> imagine that other tools have to exist. Your help would be greatly
> appreciated.
>
> Best regards,
>
> Julien
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list