4.1 Local Neighbor Match Test

The local neighbor match test (2020) is a method to identify significant locations by assessing the extent of overlap between k-nearest neighbors in geographical space and k-nearest neighbors in multi-attribute space. For more information, please read https://geodacenter.github.io/workbook/6c_local_multi/lab6c.html#local-neighbor-match-test

neighbor_match_test()

neighbor_match_test() is a PostgreSQL WINDOW function. Please call it with an OVER clause.

Synopsis

Short version:

float[] neighbor_match_test(geometry the_geom, anyarray vals, integer k)

Long version:

float[] neighbor_match_test(geometry the_geom, anyarray vals, integer k,
    character varying scale_method,
    character varying distance_method
)

Full version:

float[] neighbor_match_test(geometry the_geom, anyarray vals, integer k,
    character varying scale_method,
    character varying distance_method
    float power, 
    boolean is_inverse, 
    boolean is_arc
    boolean is_mile
)

Arguments

Name

Type

Description

the_geom

geometry

the geometry column (only points and polygons are supported)

vals

anyarray

an array of numeric columns that contains the values for neighbor match test

k

integer

k nearest neighbor for both attribute and geographical space

scale_method

character varying

the scaling method. Options are {'raw', 'standardize', 'demean', 'mad', 'range_standardize', 'range_adjust'}. Default: 'standardize'

distance_method

character varying

the distance method. Options are {'euclidean', 'manhattan'. Default: 'euclidean'.

power

float

the power/exponent corresponds to the number of times the base (dist_band) is used as a factor. Default: 1.

is_inverse

boolean

if apply inverse on distance value. Default: False.

is_arc

boolean

if compute arc distance between two observations. Default: FALSE.

is_mile

boolean

if convert distance unit from mile to kilometer(KM). Default: TRUE.

Return

Type

Description

float[]

an array contains 2 values, which are {'cardinality', 'probability'}

cardinality: the number of common neighbors for each location

Examples

Apply local neighbor match test on 6 nearest neighbors of the variables ["hr60", "ue60"] (homicide and unemployment rate 1960 in natregimes dataset):

Please see chapter 'Contiguity Based Weights' for how to create a Queen contiguity weights.

SELECT neighbor_match_test(the_geom, ARRAY[hr60, ue60], 6) OVER() FROM natregimes;

   neighbor_match_test    
--------------------------
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {0,-1}
 {1,0.0115787398060671}
 {1,0.0115787398060671}
 ...

Last updated

Was this helpful?