Skip to contents

Neighbour graphs: knn (k nearest, ties by index, as spdep::knn2nb(knearneigh())), distance (\(d_{min} < d_{ij} \le threshold\), spdep::dnearneigh), gabriel and relative (spdep::gabrielneigh, relativeneigh) and delaunay; valued weights inverse (\(d^{-\alpha}\) in the band) and kernel (uniform, triangular, Epanechnikov, quartic or Gaussian kernel of \(d/h\), h adaptive k-th neighbour distance by default). Coding styles of spdep::nb2listw: B, W, C, U, S (Tiefelsdorf, Griffith and Boots 1999) and minmax. Also returns the neighbour lists, islands, connected components, sparsity and the constants S0, S1, S2.

Usage

SpatialWeights(
  coords,
  method = "knn",
  k = 5L,
  threshold = NULL,
  row_standardize = TRUE,
  style = NULL,
  d_min = 0,
  alpha = 1,
  bandwidth = NULL,
  kernel = "gaussian"
)

Arguments

coords

Coordinates (n x 2).

method

"knn", "distance", "inverse", "kernel", "gabriel", "relative" or "delaunay".

k

Neighbours for knn and the adaptive bandwidth.

threshold

Upper distance (default median inter-point distance).

row_standardize

Row-standardise when style is NULL.

style

Coding style.

d_min

Lower distance.

alpha

Inverse-distance power.

bandwidth

Kernel bandwidth.

kernel

Kernel name.

Value

List with W, neighbours, style, n_islands, components, n_components, sparsity, S0, S1, S2, symmetric, mean_neighbours.

References

Anselin L (1988). Spatial Econometrics: Methods and Models. Kluwer.

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

Examples

SpatialWeights(rbind(c(0, 0), c(1, 0), c(0, 1), c(1, 1), c(0.5, 0.5)), "gabriel",
  style = "B")$neighbours
#> [[1]]
#> [1] 2 3 5
#> 
#> [[2]]
#> [1] 1 4 5
#> 
#> [[3]]
#> [1] 1 4 5
#> 
#> [[4]]
#> [1] 2 3 5
#> 
#> [[5]]
#> [1] 1 2 3 4
#>