nb2mat                 package:spdep                 R Documentation

_S_p_a_t_i_a_l _w_e_i_g_h_t_s _m_a_t_r_i_c_e_s _f_o_r _n_e_i_g_h_b_o_u_r_s _l_i_s_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     The function generates a weights matrix for a neighbours list with
     spatial weights for the chosen coding scheme.

_U_s_a_g_e:

     nb2mat(neighbours, glist=NULL, style="W", zero.policy=FALSE)
     listw2mat(listw)

_A_r_g_u_m_e_n_t_s:

neighbours: an object of class 'nb'

   glist: list of general weights corresponding to neighbours

   style: 'style' can take values W, B, C, and S

zero.policy: If FALSE stop with error for any empty neighbour sets, if
          TRUE permit the weights list to be formed with zero-length
          weights vectors

   listw: a 'listw' object from for example 'nb2listw'

_D_e_t_a_i_l_s:

     Starting from a binary neighbours list, in which regions are
     either listed as neighbours or are absent (thus not in the set of
     neighbours for some definition), the function creates an n by n
     weights matrix with values given by the coding scheme style
     chosen. B is the basic binary coding, W is row standardised, C is
     globally standardised, while S is the variance-stabilizing coding
     scheme proposed by Tiefelsdorf et al. 1999, p. 167-168.

     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.

_V_a_l_u_e:

     An n by n matrix, where n=length(neighbours)

_A_u_t_h_o_r(_s):

     Roger Bivand Roger.Bivand@nhh.no

_R_e_f_e_r_e_n_c_e_s:

     Tiefelsdorf, M., Griffith, D. A., Boots, B. 1999 A
     variance-stabilizing coding scheme for spatial link matrices,
     Environment and Planning A, 31, pp. 165-180.

_S_e_e _A_l_s_o:

     'nb2listw'

_E_x_a_m_p_l_e_s:

     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)))

