nb2mat(neighbours, glist=NULL, style="W", zero.policy=FALSE)
listw2mat(listw)
nb
style
can take values W, B, C, and Slistw
object from for example nb2listw
The function leaves matrix rows as zero for any regions with zero neighbours fore zero.policy TRUE. These will in turn generate lag values of zero, equivalent to the sum of products of the zero row t(rep(0, length=length(neighbours))) %*% x
, for arbitraty numerical vector x
of length length(neighbours)
. The spatially lagged value of x for the zero-neighbour region will then be zero, which may (or may not) be a sensible choice.
nb2listw
data(columbus)
col005 <- dnearneigh(coords, 0, 0.5, attr(col.gal.nb, "region.id"))
summary(col005)
col005.w.mat <- nb2mat(col005, zero.policy=TRUE)
table(round(apply(col005.w.mat, 1, sum)))
Run the code above in your browser using DataLab