14.7 Contiguous Neighbors
For each observation, the poly2nb
function checks whether
- at least one (
queen = TRUE
) - at least two (“rook”,
queen = FALSE
)
points are within snap
distance of each other.
## Neighbour list object:
## Number of regions: 2495
## Number of nonzero links: 14242
## Percentage nonzero weights: 0.2287862
## Average number of links: 5.708216
s2
spherical coordinates are used by default- symmetric relationships assumed
row.names
may be customized
14.7.1 Connected
Are the data connected? (Some model estimation techniques do not support graphs that are not connected.)
verbose code
#library(Matrix, warn.conflicts = FALSE)
#library(spatialreg, warn.conflicts = FALSE)
nb_q |>
nb2listw(style = "B") |>
as("CsparseMatrix") -> smat
#library(igraph, warn.conflicts = FALSE)
smat |> graph.adjacency() -> g1
## Warning: `graph.adjacency()` was deprecated in igraph 2.0.0.
## ℹ Please use `graph_from_adjacency_matrix()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## [1] 1