Create spatial and space-time connectivity matrices
Create spatial and space-time connectivity matrices
Creates sparse matrix representations of spatial connectivity structures
Source
Bivand, Roger S. and Pebesma, Edzer and Gomez-Rubio, Virgilio (2013). Applied spatial data analysis with R, Second edition. Springer, NY. https://asdar-book.org/
Griffith, Daniel A. (2012). Space, time, and space-time eigenvector filter specifications that account for autocorrelation. Estadística Espanola, 54(177), 7-34.
Haining, Robert P. and Li, Guangquan (2020). Modelling Spatial and Spatial-Temporal Data: A Bayesian Approach. CRC Press.
shape: An object of class sf, SpatialPolygons or SpatialPolygonsDataFrame.
style: What kind of coding scheme should be used to create the spatial connectivity matrix? Defaults to "B" for binary; use "W" for row-standardized weights.
queen: Deprecated: use the method' argument instead. This option is passed to poly2nbto set the contiguity condition. Defaults toTRUE` so that a single shared boundary point (rather than a shared border/line) between polygons is sufficient for them to be considered neighbors.
method: Method for determining neighbors: queen, rook, or k-nearest neighbors. See Details for more information.
k: Number of neighbors to select for k-nearest neighbor method. Passed to spdep::knearneigh.
longlat: If longlat = TRUE, Great Circle (rather than Euclidean) distances are used; great circle circle distances account for curvature of the Earth.
snap: Passed to spdep::poly2nb; "boundary points less than ‘snap’ distance apart are considered to indicate contiguity."
t: Number of time periods. Only the binary coding scheme is available for space-time connectivity matrices.
st.style: For space-time data, what type of space-time connectivity structure should be used? Options are "lag" for the lagged specification and "contemp" (the default) for contemporaneous specification (see Details).
quiet: If TRUE, messages will be silenced.
Returns
A spatial connectivity matrix in sparse matrix format. Binary matrices are of class ngCMatrix, row-standardized are of class dgCMatrix, created by sparseMatrix.
Details
The method argument currently has three options. The queen contiguity condition defines neighbors as polygons that share at least one point with one another. The rook condition requires that they share a line or border with one another. K-nearest neighbors is based on distance between centroids. All methods are implemented using the spdep package and then converted to sparse matrix format.
Alternatively, one can use spdep directly to create a listw object and then convert that to a sparse matrix using as(listw, 'CsparseMatrix') for use with geostan.
Haining and Li (Ch. 4) provide a helpful discussion of spatial connectivity matrices (Ch. 4).
The space-time connectivity matrix can be used for eigenvector space-time filtering (stan_esf. The 'lagged' space-time structure connects each observation to its own past (one period lagged) value and the past value of its neighbors. The 'contemporaneous' specification links each observation to its neighbors and to its own in situ past (one period lagged) value (Griffith 2012, p. 23).
Examples
data(georgia)## binary adjacency matrixC <- shape2mat(georgia,"B", method ='rook')## number of neighbors per observationsummary( n_nbs(C))head(Matrix::summary(C))## row-standardized matrix W <- shape2mat(georgia,"W", method ='rook')## summary of weightsE <- edges(W, unique_pairs_only =FALSE)summary(E$weight)## space-time matricies ## for eigenvector space-time filtering## if you have multiple years with same geometry/geography,## provide the geometry (for a single year!) and number of years \code{t}Cst <- shape2mat(georgia, t =5)dim(Cst)EVst <- make_EV(Cst)dim(EVst)