<html dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style title="owaParaStyle"><!--P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
--></style>
<meta name="GENERATOR" content="MSHTML 8.00.6001.18882">
</head>
<body ocsi="x">
<div dir="ltr"><font color="#000000" size="2" face="Tahoma"><font size="3">Hi everyone,<br>
<br>
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:<br>
---------------------------------------------------------------------------------------<br>
   shape <- readShapePoly("path_to_my_shapefile", IDvar="Id")<br>
   shape_nb<-poly2nb(shape)<br>
<br>
   data<-list(</font></font></div>
<div>
<div dir="ltr"><font color="#000000" size="2" face="Tahoma"><font size="3"><font face="tahoma">  
</font>N = length(shape_nb),<br>
   num=sapply(shape_nb, length),<br>
   adj=unlist(shape_nb),<br>
   lst = attr(shape_nb, "region.id"),<br>
   adj2 = lst[unlist(shape_nb)],<br>
   sumNumNeigh=length(unlist(shape_nb)</font></font></div>
<div dir="ltr"><font color="#000000" size="2" face="Tahoma"><font size="3">   )<br>
----------------------------------------------------------------------------------------<br>
</div>
</font></font>
<div dir="ltr"><font color="#000000" size="2" face="Tahoma"><font size="3">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.<br>
<br>
Best regards,<br>
<br>
Julien</font><br>
</div>
</font></div>
</body>
</html>