Convert a square spatial weights matrix to a weights list object
Convert a square spatial weights matrix to a weights list object
The function converts a square spatial weights matrix, optionally a sparse matrix to a weights list object, optionally adding region IDs from the row names of the matrix, as a sequence of numbers 1:nrow(x), or as given as an argument. The style can be imposed by rebuilting the weights list object internally.
x: A square non-negative matrix with no NAs representing spatial weights; may be a matrix of class sparseMatrix
row.names: row names to use for region IDs
style: default NULL, missing, set to "M" and warning given; if not "M", passed to nb2listw to re-build the object
zero.policy: default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors
Returns
A listw object with the following members: - style: "M", meaning matrix style, underlying style unknown, or assigned style argument in rebuilt object
neighbours: the derived neighbours list
weights: the weights for the neighbours derived from the matrix