Implements the Local Neighbor Match Test as described in Tobler's Law in a Multivariate World (Anselin and Li, 2020).
Usage
nb_match_test(
x,
nb,
wt = st_weights(nb),
k = 10,
nsim = 499,
scale = TRUE,
.method = "euclidian",
.p = 2
)
Arguments
- x
a numeric vector or a list of numeric vectors of equal length.
- nb
a neighbor list object for example as created by
st_contiguity()
.- wt
a weights list as created by
st_weights()
.- k
the number of neighbors to identify in attribute space. Should be the same as number of neighbors provided in st_knn.
- nsim
the number of simulations to run for calculating the simulated p-value.
- scale
default
TRUE
. Whetherx
should be scaled or not. Note that measures should be standardized.- .method
default
"euclidian"
. The distance measure passed tostats::dist()
.- .p
default 2. The power of Minkowski distance passed to the
p
argument instats::dist()
.
Examples
guerry %>%
dplyr::transmute(nb = st_knn(geometry, k = 10),
nmt = nb_match_test(list(crime_pers, literacy, suicides),
nb, nsim = 999)) %>%
tidyr::unnest(nmt)
#> ! Polygon provided. Using centroid.
#> Loading required namespace: dbscan
#> Simple feature collection with 85 features and 6 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -5.139026 ymin: 42.33349 xmax: 8.23032 ymax: 51.08939
#> Geodetic CRS: WGS 84
#> # A tibble: 85 × 7
#> nb n_shared nb_matches knn_nb probability p_sim geometry
#> <nb> <int> <list> <list> <dbl> <dbl> <MULTIPOLYGON [°]>
#> 1 <int … 1 <int [1]> <int … 0.400 0.651 (((4.92452 45.80404, 4.9…
#> 2 <int … 4 <int [4]> <int … 0.0141 0.022 (((4.126445 49.67821, 4.…
#> 3 <int … 4 <int [4]> <int … 0.0141 0.015 (((3.773349 46.22719, 3.…
#> 4 <int … 4 <int [4]> <int … 0.0141 0.022 (((5.872688 44.22421, 5.…
#> 5 <int … 0 <int [0]> <int … 0.260 0.276 (((5.921825 44.24841, 5.…
#> 6 <int … 0 <int [0]> <int … 0.260 0.271 (((4.177986 44.31775, 4.…
#> 7 <int … 5 <int [5]> <int … 0.00147 0.001 (((5.361486 49.59208, 5.…
#> 8 <int … 5 <int [5]> <int … 0.00147 0.004 (((1.229289 42.72774, 1.…
#> 9 <int … 3 <int [3]> <int … 0.0782 0.073 (((4.690867 48.08597, 4.…
#> 10 <int … 4 <int [4]> <int … 0.0141 0.013 (((2.659241 43.29298, 2.…
#> # … with 75 more rows