{{Short description|Neighbor Matrix}}

The concept of a '''spatial weight''' is used in spatial analysis to describe neighbor relations between regions on a map.<ref name="clifford"> {{cite book | title=Spatial Processes: Models & Applications | author=Cliff, A.D. and Ord, J.K. | isbn=9780850860818 | url=https://books.google.com/books?id=Mi0OAAAAQAAJ | year=1981 | publisher=Pion }}</ref> If location <math>i</math> is a neighbor of location <math>j</math> then <math>w_{ij} \neq 0</math> otherwise <math>w_{ij} = 0</math>. Usually (though not always) we do not consider a site to be a neighbor of itself<ref name="geoda1">{{cite web | url=https://geodacenter.github.io/workbook/4a_contig_weights/lab4a.html | title=Contiguity-Based Spatial Weights }}</ref> so <math>w_{ii} = 0</math>. These coefficients are encoded in the '''spatial weight matrix''' :<math> W = \begin{pmatrix} w_{11} & w_{12} & \ldots & w_{1N} \\ w_{21} & w_{22} & \ldots & w_{2N} \\ \vdots & \vdots & \vdots & \vdots \\ w_{N1} & w_{N2} & \ldots & w_{NN} \\ \end{pmatrix} </math> Where <math>N</math> is the number of sites under consideration. The spatial weight matrix is a key quantity in the computation of many spatial indices like Moran's I, Geary's C, Getis-Ord statistics and Join Count Statistics.

== Contiguity-Based Weights ==

thumb|Common connectivity patterns described on a regular grid. Non-zero values of <math>w_{Aj}</math> are indicated by the red lines. For example in the rook's case, for the <math>A</math> row of the weight matrix only <math>w_{AN}, w_{AS}, w_{AE}, w_{AW} \neq 0</math> and similarly in the other cases.

This approach considers spatial sites as nodes in a graph with links determined by a shared boundary or vertex.<ref name="fortindale">Dale MR, Fortin MJ. Spatial analysis: a guide for ecologists. Cambridge University Press; 2014 Sep 11.</ref> The elements of the spatial weight matrix are determined by setting <math>w_{ij} = 1</math> for all connected pairs of nodes <math>ij</math> with all the other elements set to 0. This makes the spatial weight matrix equivalent to the adjacency matrix of the corresponding network. It is common<ref name="geoda1"/> to row-normalize the matrix <math>W</math>, :<math>w_{ij} \rightarrow w_{ij}/\sum_j w_{ij}</math> In this case the sum of all the elements of <math>W</math> equals <math>N</math> the number of sites.

thumb|African quadripoint. Using Rook neighbors, Zimbabwe is neighbours with Zambia and Botswana. Using Queen neighbors, Zimbabwe is also a neighbor of Namibia. Bishop neighbors are rarely used for polygonal data. There are three common methods for linking sites<ref name="fortindale" /> named after the chess pieces which make similar moves: * Rook: sites are neighbors if they share an edge * Bishop: sites are neighbours if they share a vertex * Queen: sites are neighbours if they share an edge or a vertex

In some cases statistics can be quite different depending on the definition used, especially for discrete data on a grid.<ref name="fortindale" /> There are also other cases where the choice of neighbors is not obvious and can affect the outcome of the analysis. Bivand and Wong<ref>Bivand RS, Wong DW. Comparing implementations of global and local indicators of spatial association. Test. 2018 Sep;27(3):716-48.</ref> describe a situation where the value of spatial indices of association (like Moran's I) depend on the inclusion or exclusion of a ferry crossing between counties. There are also cases where regions meet in a tripoint or quadripoint where Rook and Queen neighborhoods can differ.

== Distance-Based Weights ==

Another way to define spatial neighbors is based on the distance between sites. One simple choice is to set <math>w_{ij} = 1</math> for every pair <math>(i,j)</math> separated by a distance less than some threshold <math>\delta</math>.<ref name="geoda2">{{cite web | url=https://geodacenter.github.io/workbook/4b_dist_weights/lab4b.html | title=Distance-Band Spatial Weights }}</ref> Cliff and Ord<ref name="clifford"/> suggest the general form :<math> w_{ij} = g(d_{ij}, \beta_{ij}) </math> Where <math>g</math> is some function of <math>d_{ij}</math> the distance between <math>i</math> and <math>j</math> and <math>\beta_{ij}</math> is the proportion of the perimeter of <math>i</math> in contact with <math>j</math>. The function :<math> w_{ij} = d_{ij}^{-\alpha} \beta_{ij}^{b} </math> is then suggested. Often the <math>\beta</math> term is not included and the most common values for <math>\alpha</math> are 1 and 2.<ref name="fortindale" /> Another common choice for the distance decay function is<ref name="geoda3">{{cite web | url=https://geodacenter.github.io/workbook/4c_distance_functions/lab4c.html | title=Spatial Weights as Distance Functions }}</ref> :<math> w_{ij} = \exp( - d_{ij} ) </math> though a number of different Kernel functions can be used. The exponential and other Kernel functions typically set <math>w_{ii} = 1</math> which must be considered in applications.

It is possible to make the spatial weight matrix a function of 'distance class':<ref>Legendre P, Legendre L. Numerical ecology. Elsevier; 2012 Jul 21.</ref> <math>w_{ij} \rightarrow w_{ij}(d)</math> where <math>d</math> denotes the 'distance class', for example <math>d=1,2,3,\ldots</math> corresponding to first, second, third etc. neighbors. In this case, functions of the spatial weight matrix become distance class dependent. For example, Moran's I is :<math> I(d) = \frac{ N }{|W(d)|} \frac {\sum_{i=1}^N \sum_{j=1}^N w_{ij}(d)(x_i-\bar x) (x_j-\bar x)} {\sum_{i=1}^N (x_i-\bar x)^2} </math> This defines a type of spatial correlogram, in this case, since Moran's ''I'' measures spatial autocorrelation, <math>I(d)</math> measures how the autocorrelation of the data changes as a function of distance class. Remembering Tobler's first law of geography, "everything is related to everything else, but near things are more related than distant things" it usually decreases with distance.

Common distance functions include<ref name="geoda2" /> Euclidean distance, Manhattan distance and Great-circle distance.

== Spatial Lag ==

One application of the spatial weight matrix is to compute the '''spatial lag'''<ref>{{cite web | url=https://geodacenter.github.io/workbook/4d_weights_applications/lab4d.html | title=Applications of Spatial Weights }}</ref> :<math> [Wx]_i = \sum_j w_{ij} x_j </math> For row-standardised weights initially set to <math>w_{ij} = 1</math> and with <math>w_{ii} = 0</math>, <math>[Wx]_i</math> is simply the average value observed at the neighbors of <math>i</math>. These lagged variables can then be used in regression analysis to incorporate the dependence of the outcome variable on the values at neighboring sites.<ref>Anselin L, Griffith DA. Do spatial effecfs really matter in regression analysis?. Papers in Regional Science. 1988 Jan 1;65(1):11-34.</ref> The standard regression equation is :<math> y_i = \sum_k x_{ik} \beta_k + \epsilon_i </math> The ''spatial lag model'' adds the spatial lag vector to this :<math> y_i = \rho\sum_j w_{ij}y_j + \sum_k x_{ik} \beta_k + \epsilon_i </math> where <math>\rho</math> is a parameter which controls the degree of autocorrelation of <math>y</math>.<ref>Seya H, Yoshida T, Yamagata Y. Spatial econometric models. InSpatial Analysis Using Big Data 2020 Jan 1 (pp. 113-158). Academic Press.</ref> This is similar to an autoregressive model in the analysis of time series.

== See also ==

* Spatial Analysis * Moran's I * Geary's C * Join Count Statistics

== References == {{reflist}}

Category:Spatial analysis Category:Covariance and correlation