Skip to content
Prev 22390 / 29559 Next

Create listw or nb object from binary edge matrix

On Sat, 28 Feb 2015, jcoyle wrote:

            
I suppose you meant:

library(spdep)
mat = matrix(0, 4, 4)
mat[1,2] = 1
mat[2,1] = 1
mat[3,4] = 1
mat[4,3] = 1
   mat
lw = mat2listw(mat)
lw$neighbors

but

lw$neighbours

is OK, as:

all.equal(nb2mat(lw$neighbours, style="B"), mat, check.attributes=FALSE)

shows. Use of British English spelling is rooted in usage in Cliff & Ord 
(1973).

Roger