# II: Modeling the spatial behavior of economic agents in a given set of locations

## Preliminary definitions and concepts

### Neighborhood and the W matrix

The classical linear regression model assumes normal, exogenous and spherical disturbances (Greene, 2018). However, when we observe a phenomenon in, say, n regions, non-sphericalness of residuals may arise due to the presence of spatial autocorrelation and spatial heterogeneity among the stochastic terms, in which case the optimal properties of the ordinary least squares (OLS) are lost. Before introducing various alternatives to the basic model, let us, however, introduce some preliminary concepts. In fact, we can intuitively define spatial correlation as a feature of data describing the fact that observations that are close together are more correlated than observations that are far apart (the “first law of geography” (Tobler, 1970)). However, a formal definition requires a clarification of the concept of “closeness”. At the heart of spatial econometrics methods is the definition of the so-called “weights matrix” (or “connectivity matrix”). The simplest of all definitions is the following: in which each generic element is defined as N(i) being the set of neighbors of location j. By definition we have that wu = 0.

Many different alternative definitions of the W matrix are possible.

A first definition is based on an inverse function of the distance: Wij = d~"; a > 0 where often « = 2 due to the analogy with Newton’s law of universal gravitation. This first definition, however, presents the disadvantage of producing very dense W matrices an issue that can create computational problems with very large datasets.

A second definition considers a threshold distance (say d ) introduced to increase the sparseness of the W matrix thus reducing the computational problems emerging when dealing with large datasets (see Figure 2.1b). We can then have

I 1 if dj, < d

simple binary matrices where Wjj = 1 J or, alternatively, a combina-

0 otherwise

d~a if djs < d

tion with the inverse distance definition where Wjj = 1 J . Finally,

• 0 otherwise
• 11 if i g N^(i)
• 7 where
• 0 otherwise

Nk(i) is the set of the к nearest neighbors to point i (see Figure 2.1a).

Quite often the W matrices are standardized to sum unity in each row an operation called “row standardization”. In this case we have: This standardization may be very useful in some instances. For example, by using the standardized weights we can define the matrix product in which each single element is equal to: Figure 2.1 K-nearest neighbors contiguity criterion (k = 4): (a) only the first k nearest neighbors are considered; maximum threshold criterion; (b) all points within a radius d* are considered neighbors to the point located in the center.

Preliminary definitions and concepts 17 with #N(i) representing the cardinality of the set N(i). The term in Equation 2.5 represents the average of variable у observed in all the individuals that are neighbors to individual i (according to the criterion chosen in defining TV). It therefore assumes the meaning of the “spatially lagged value” of у,- and for this reason is often indicated with the symbol L(y) by analogy with the lag operator in time-series analysis. This definition assumes no directional bias in that all neighbors affect individual i in the same way (for alternatives, see Arbia, 1990; Arbia et al., 2013). An important aspect of W matrices is represented by their “density”, defined

Tl — 1

as the percentage of non-zero entries a value that ranges between 0 and-

n

when all off-diagonal entries are non-zero. The complement to 1 of the density is called the “sparsity” of a matrix. Dense W matrices should be avoided as they may involve severe computational problems in terms of computing time, storage and accuracy especially when the sample size is very large (see Arbia et. ah, 2019b).

Example 2.1

Some simple examples of W matrices for sets of points are reported here. Consider, initially, a map of ten individual points (Figure 2.2). From this dataset we can build up four different W matrices employing the different neighborhood criteria illustrated above.

i The first W matrix can be built up as a simple binary threshold distance by fixing a conventional threshold at a distance of, say, 0.45 (R Command: {spdep(-dnearneigh) (Table 2.1). The matrix can then be row-standardized obtaining Table 2.2.

ii The second alternative is to build up a W matrix using the nearest neighbor criterion (R Command: jspdep)-knearneigh). We obtain Table 2.3, which is standardized by definition.

iii As a third alternative we consider the squared inverse distance criterion. We first obtain the pair-wise distance matrix (Table 2.4) and then the W matrix is obtained calculating in each entry the squared inverse distance (keeping 0 in the main diagonal) (Table 2.5), which can be row-standardized, obtaining Table 2.6.

iv Finally we build up a combination of cases ii and iii using the squared inverse distance below a threshold (<0.45). The unstandardized version is in Table 2.7, which, once row-standardized, becomes Table 2.8. Figure 2.2 Map of ten points in a unit square.

Table 2.1 Binary threshold distance W matrix (threshold = 0.45) built on the basis of the points reported in Figure 2.2 (unstandardized)

Row sum

 0 0 0 1 0 0 0 1 0 0 2 0 0 1 1 0 1 0 0 0 0 3 0 1 0 1 0 0 1 0 0 0 3 1 1 1 0 0 0 1 0 1 0 5 0 0 0 0 0 1 0 0 1 1 3 0 1 0 0 1 0 0 0 1 0 3 0 0 1 1 0 0 0 0 0 0 2 1 0 0 0 0 0 0 0 1 1 3 0 0 0 1 1 1 0 1 0 1 5 0 0 0 0 1 0 0 1 1 0 3

Preliminary definitions and concepts 19

Table 2.2 Binary threshold distance W matrix (threshold = 0.45) built on the basis of the points reported in Figure 2.2 (row standardized)

 Rom sum 0.00 0.00 0.00 0.50 0.00 0.00 0.00 0.50 0.00 0.00 1.00 0.00 0.00 0.33 0.33 0.00 0.33 0.00 0.00 0.00 0.00 1.00 0.00 0.33 0.00 0.33 0.00 0.00 0.33 0.00 0.00 0.00 1.00 0.20 0.20 0.20 0.00 0.00 0.00 0.20 0.00 0.20 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.33 0.00 0.00 0.33 0.33 1.00 0.00 0.33 0.00 0.00 0.33 0.00 0.00 0.00 0.33 0.00 1.00 0.00 0.00 0.50 0.50 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.33 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.33 0.33 1.00 0.00 0.00 0.00 0.20 0.20 0.20 0.00 0.20 0.00 0.20 1.00 0.00 0.00 0.00 0.00 0.33 0.00 0.00 0.33 0.33 0.00 1.00

Table 2.3 Nearest neighbor distance W matrix built on the basis of the points reported in Figure 2.2

 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0

Table 2.4 Pair-wise distance matrix of the points reported in Figure 2.2

 0 0.844 0.486 0.416 0.702 0.84 0.519 0.329 0.578 0.728 0.844 0 0.434 0.436 0.722 0.433 0.518 0.895 0.691 0.887 0.486 0.434 0 0.245 0.757 0.662 0.122 0.673 0.662 0.877 0.416 0.436 0.245 0 0.515 0.479 0.36 0.482 0.418 0.633 0.702 0.722 0.757 0.515 0 0.359 0.875 0.464 0.125 0.17 0.84 0.433 0.662 0.479 0.359 0 0.781 0.723 0.396 0.527 0.519 0.518 0.122 0.36 0.875 0.781 0 0.751 0.775 0.989 0.329 0.895 0.673 0.482 0.464 0.723 0.751 0 0.354 0.433 0.578 0.691 0.662 0.418 0.125 0.396 0.775 0.354 0 0.217 0.728 0.887 0.877 0.633 0.17 0.527 0.989 0.433 1 0

20 Spatial behavior of economic agents

Table 2.5 Squared inverse distance W matrix built on the basis of the points reported in Figure 2.2 (unstandardized)

 0 1.405 4.233 5.791 2.027 1.416 3.718 9.259 2.995 1.889 1.405 0 5.32 5.25 1.918 5.327 3.731 1.25 2.091 1.271 4.233 5.32 0 16.723 1.743 2.283 67.63 2.205 2.28 1.299 5.791 5.25 16.723 0 3.774 4.351 7.721 4.304 5.731 2.494 2.027 1.918 1.743 3.774 0 7.738 1.307 4.651 64.476 34.587 1.416 5.327 2.283 4.351 7.738 0 1.638 1.913 6.371 3.597 3.718 3.731 67.63 7.721 1.307 1.638 0 1.771 1.663 1.023 9.259 1.25 2.205 4.304 4.651 1.913 1.771 0 7.971 5.342 2.995 2.091 2.28 5.731 64.476 6.371 1.663 7.971 0 21.289 1.889 1.271 1.299 2.494 34.587 3.597 1.023 5.342 21.289 0

Table 2.6 Squared inverse distance W matrix built on the basis of the points reported in Figure 2.2 (row standardized)

 Roil’ sum 0.000 0.043 0.129 0.177 0.062 0.043 0.114 0.283 0.091 0.058 1.000 0.051 0.000 0.193 0.190 0.070 0.193 0.135 0.045 0.076 0.046 1.000 0.041 0.051 0.000 0.161 0.017 0.022 0.652 0.021 0.022 0.013 1.000 0.103 0.094 0.298 0.000 0.067 0.077 0.138 0.077 0.102 0.044 1.000 0.017 0.016 0.014 0.031 0.000 0.063 0.011 0.038 0.528 0.283 1.000 0.041 0.154 0.066 0.126 0.223 0.000 0.047 0.055 0.184 0.104 1.000 0.041 0.041 0.750 0.086 0.014 0.018 0.000 0.020 0.018 0.011 1.000 0.239 0.032 0.057 0.111 0.120 0.049 0.046 0.000 0.206 0.138 1.000 0.026 0.018 0.020 0.050 0.561 0.055 0.014 0.069 0.000 0.185 1.000 0.026 0.017 0.018 0.034 0.475 0.049 0.014 0.073 0.292 0.000 1.000

Table 2.7 Squared inverse distance with a threshold (0.45) W matrix built on the basis of the points reported in Figure 2.2 (unstandardized)

 0 0 0 5.791 0 0 0 9.259 0 0 0 0 5.32 5.25 0 5.327 0 0 0 0 0 5.32 0 16.723 0 0 67.63 0 0 0 5.791 5.25 16.723 0 0 0 7.721 0 5.731 0 0 0 0 0 0 7.738 0 0 64.476 34.587 0 5.327 0 0 7.738 0 0 0 6.371 0 0 0 67.63 7.721 0 0 0 0 0 0 9.259 0 0 0 0 0 0 0 7.971 5.342 0 0 0 5.731 64.476 6.371 0 7.971 0 21.289 0 0 0 0 0.029 0 0 0.187 0 0

Preliminary definitions and concepts 21

Table 2.8 Squared inverse distance with a threshold (0.45) W matrix built on the basis of the points reported in Figure 2.2 (row standardized)

 Rom sum 0.000 0.000 0.000 0.385 0.000 0.000 0.000 0.615 0.000 0.000 1.000 0.000 0.000 0.335 0.330 0.000 0.335 0.000 0.000 0.000 0.000 1.000 0.000 0.059 0.000 0.186 0.000 0.000 0.754 0.000 0.000 0.000 1.000 0.141 0.127 0.406 0.000 0.000 0.000 0.187 0.000 0.139 0.000 1.000 0.000 0.000 0.000 0.000 0.000 0.072 0.000 0.000 0.604 0.324 1.000 0.000 0.274 0.000 0.000 0.398 0.000 0.000 0.000 0.328 0.000 1.000 0.000 0.000 0.898 0.102 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.410 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.353 0.237 1.000 0.000 0.000 0.000 0.054 0.609 0.060 0.000 0.075 0.000 0.201 1.000 0.000 0.000 0.000 0.000 0.134 0.000 0.000 0.866 0.000 0.000 1.000

The various definitions present relative advantages and drawbacks. In particular, the distance threshold criterion (case i) may produce isolated locations with no neighbors if the threshold is too small which makes it impossible to derive the spatially lagged variable. On the other hand, it may lead to very dense matrices with each location related to many others (possibly all of them) if we are forced to use a large threshold to include at least one neighbor for each location. We mentioned already the problems raised by dense W matrices. The nearest neighbor definition (case ii) produces a matrix which is not symmetrical, which can be a problem in some instances, but it should be equally remarked that none of the other definitions lead to a symmetrical matrix once they are standardized.

Similarly to case i, the squared inverse distance criterion (case iii) leads by definition to fully dense matrices, so that a reasonable compromise could be represented by the squared inverse distance with a threshold (case iv).

Example 2.2

Now suppose that in the ten locations reported in the point pattern of Example 2.1, we observe the following values of a hypothetical variable Y:

 Location 1 2 3 4 5 6 7 8 9 10 Y 102 113 103 116 94 115 100 91 91 103

Using the four different W matrices described above we can calculate the spatially lagged variable using the expression reported in Equation 2.5 (R Command: (spdep)-lag.listw). We obtain Table 2.9.

Table 2.9 Spatially lagged variable computed using four different neighborhood criteria

 Y Spatial lag, L(Y) Threshold distance Nearest neighbor Squared inverse distance Squared inverse distance with threshold 102 103 91 101 101 113 110 115 105 111 103 108 100 103 103 116 102 103 102 102 94 102 91 98 97 115 98 94 101 98 100 110 103 104 105 91 98 102 101 99 91 104 94 98 98 103 91 94 95 91