spatial and regional economic analysis mini-course

81
Vicente Rios Spatial and Regional Economic Analysis Mini-Course: Author: Vicente Rios

Upload: others

Post on 19-Dec-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Spatial and Regional Economic Analysis

Mini-Course:

Author: Vicente Rios

Page 2: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice: Spatial Weight Matrices for European

Regions

Testing Spatial Autocorrelation

Global Spatial Autocorrelation

Local Spatial Autocorrelation

Practice: Unemployment Rate Spatial

Autocorrelation Analysis

Lecture 2: Introduction Spatial Analysis

2

Page 3: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

We are going to put in practice some of previous ideas/concepts by

developing W matrices to describe connectivity among European

NUTS-2 regions

NUTS-2 regions (Nomenclature of Territorial Units for Statistics)

NUTS2 is the territorial unit most commonly used in the literature

on regional analysis in the EU

NUTS2 regions are the basic unit for the application of cohesion

policies in the EU

(http://ec.europa.eu/regional_policy/sources/docoffic/official/repo

rts/cohesion7/7cr.pdf)

Spanish Autonomous Communities, French regions, etc..

NUTS-x refers to a level of data aggregation (3 is provinces, 0 are

countries, 1(is intermediate between country aggrregation and

regional aggregation))

Practice (W matrices)

3

Page 4: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (W matrices)

4

Page 5: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

In Italy there are 20 NUTS-2 regions

NUTS-2 regions

5

Page 6: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

In Germany this is the current NUTS-2 regional division:

NUTS-2 regions

6

Page 7: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Switch to Matlab โ€œTutorial1_W_Matrices.mโ€

7

Page 8: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Goals

In a first place, we are going to use latitude and longitude

coordinates of each NUTS2 region to obtain a matrix of

distances ๐‘ซ๐’Š๐’‹ in kilometers for all European regions.

Second, we will use this distance matrix ๐‘ซ๐’Š๐’‹ to derive different

spatial weight matrices W using some of the spatial functional

forms we have seen before.

In particular we will derive (i) the gravity W matrix, (ii) the 5 and

25 nearest neighbors and (iii) an exponential matrix with cut-offs

at the first quartile of the distribution of distances.

Practice (W matrices)

8

Page 9: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Software: Matlab

We are going to use some already built in functions in this exercise:

1) distance.mโ†’ calculates distances (in degrees) between points in a sphere

2) deg2km.m โ†’ converts degrees into kilometers

3) normw.mโ†’ row-normalizes the matrices

4) make_nnw.mโ†’ finds โ€œkโ€ nearest neighbors and builts W based on the specified k

5) spy.mโ†’ plots the sparsity pattern of a matrix

6) vec.mโ†’ vectorizes a matrix

7) quantile.mโ†’ finds quantiles of the distribution of the supplied variable

8) gplot.mโ†’ creates a network representation of a matrix

Practice (W matrices)

9

Page 10: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (W matrices)

10

Code

Page 11: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

(code continued)

Practice part 1

11

Page 12: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

(code continued)

Practice (W matrices)

12

Page 13: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

(code continued)

Practice (W matrices)

13

Page 14: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

(code continued)

Practice Day 1

14

Page 15: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

An interesting thing to do is to visualize how sparse or how dense is

our matrix.

In applied analysis matrix sparsity greatly accelerates computations.

Sparsity carries a number of substantive and computational advantages:

Dense matrices are noisy and contain a potentially large number of

irrelevant connections.

Dense matrices will bias downward indirect effects of a change in

observation j (the individual weights of non-zero entries in row-

standardized weight matrices will be smaller).

Dense matrices can be computationally intensive to the point that even

simple matrix operations are infeasible

Practice (W matrices)

15

Page 16: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Some computational facts on W sparsity:

With n = 65K

Dense Matrix = 31.9 GB of storage vs Sparse Matrix = 0.01 GB

With n = 208K

Dense Matrix = 324.8 GB of storage vs Sparse Matrix = 0.03 GB

With n = 8M (big data)

Dense Matrix = 501659.33 GB of storage vs Sparse Matrix = 1.1 GB

Ways to increase efficiency: ordering north-south or east-west

Concentrates nonzero elements around the diagonal

Log determinant of W with n=62K more than 12GB and almost infeasible in time for

most of machines

The same operation for a geographically ordered matrix takes less than a minute

Practice (W matrices)

16

Page 17: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (W matrices)

17

Page 18: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

K-nearest neighbor matrices

Practice (W matrices)

18

Page 19: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

K-nearest neighbor matrices

Practice (W matrices)

19

Page 20: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

(code continued)

Practice (W matrices)

20

Page 21: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

The gravity matrix

Practice (W matrices)

21

Page 22: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Exponential decay matrices with cut-offs

Practice (W matrices)

22

Page 23: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

5-nearest neighbor representation of NUTs-2 European regions

Practice (W matrices)

23

Page 24: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (W matrices)

24

Page 25: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Indicator of spatial association

Global Autocorrelation

Local Autocorrelation

Global Autocorrelation:

It is a measure of overall clustering in the data. It yields one statistic to

summarize the whole study area.

Captures departures from random spatial distribution

Famous/Commonly employed statistics:

Moranโ€™s I

Geryโ€™s C

Getis and Ordโ€™s G(d)

Testing Spatial Autocorrelation

25

Page 26: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Real distribution of unemployment rates in European regions (2011) vs a

spatially random distribution with the same parameters

๐‘ˆ ~ (๐œ‡ = 9.4, ๐œŽ = 5.25)

Real world vs spatial randomness

26

Page 27: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Moranโ€™s I

This statistic is given by:

๐ผ =๐‘›ฯƒ๐‘–=1

๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–๐‘› ๐‘ค๐‘–๐‘—(๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

๐‘† ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

where ๐‘† = ฯƒ๐‘–=1๐‘› ฯƒ๐‘—=1

๐‘› ๐‘ค๐‘–๐‘— and ๐‘ค๐‘–๐‘— is an element of the spatial weight matrix

that measures spatial distance or connectivity between regions i and j.

In matrix form:

๐ผ =๐‘›

๐‘†

๐‘งโ€ฒ๐‘Š๐‘ง

๐‘งโ€ฒ๐‘งwhere ๐‘ง = x โˆ’ าง๐‘ฅ. If the W matrix is row-standardized, then:

๐ผ =๐‘งโ€ฒ๐‘Š๐‘ง

๐‘งโ€ฒ๐‘งbecause S=n.

Values range from -1 (perfect dispersion) to +1 (perfect correlation). A zero

value indicates a random spatial pattern

Testing Spatial Autocorrelation

27

Page 28: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Note that:

แˆ˜๐›ฝ๐‘‚๐ฟ๐‘† =ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ ๐‘ฆ๐‘– โˆ’ เดค๐‘ฆ

๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

Therefore

๐ผ =๐‘›ฯƒ๐‘–=1

๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–๐‘› ๐‘ค๐‘–๐‘—(๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

๐‘† ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

I, is equivalent to the slope of coefficient of a linear regression of the

spatial Wx on the observation vector x, measured in deviation from their

means. เทช๐‘Š๐‘‹ = ๐›ฝ1 เทจ๐‘‹

where the tilde represents the variable is in deviation from the mean

Testing Spatial Autocorrelation

28

Page 29: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

A very useful tool for understanding the Moranโ€™s I test is the

Moranโ€™s scatterplot:

Testing Spatial Autocorrelation

29

Page 30: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐‘ฅ = ๐œŒ๐‘Š๐‘ฅ + ๐œ– โ†’ ๐‘ฅ = (๐ผ โˆ’ ๐œŒ๐‘Š)โˆ’1๐œ–

Example with ๐œŒ = 0.99

Testing Spatial Autocorrelation

30

Page 31: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐‘ฅ = ๐œŒ๐‘Š๐‘ฅ + ๐œ– โ†’ ๐‘ฅ = (๐ผ โˆ’ ๐œŒ๐‘Š)โˆ’1๐œ–

Example with ๐œŒ = 0.00

Testing Spatial Autocorrelation

31

Page 32: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐‘ฅ = ๐œŒ๐‘Š๐‘ฅ + ๐œ– โ†’ ๐‘ฅ = (๐ผ โˆ’ ๐œŒ๐‘Š)โˆ’1๐œ–

Example with ๐œŒ = โˆ’0.99

Testing Spatial Autocorrelation

32

Page 33: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Many spatial econometric based studies use Moranโ€™s I to motivate the

employment of spatial econometrics to analyze a specific variable

It can be complemented by means of spatially conditioned stochastic

kernels estimates of ๐‘” ๐‘ฆ|๐‘Š๐‘ฆ :

๐‘” ๐‘ฆ|๐‘Š๐‘ฆ =๐‘“(๐‘ฆ,๐‘Š๐‘ฆ)

๐‘“(๐‘ฆ)

where ๐‘” ๐‘ฆ|๐‘Š๐‘ฆ is the density of y conditional on the neighborโ€™s values of y

The kernel ๐‘” ๐‘ฆ|๐‘Š๐‘ฆ is a conditional density and shows the probability that a

given region has a specific value or state of y, given their neighborโ€™s values.

To estimate ๐‘” ๐‘ฆ|๐‘Š๐‘ฆ one first estimates the joint density of f ๐‘ฆ,๐‘Š๐‘ฆ and

then the marginal density ๐‘“ ๐‘ฆ is calculated by integrating over y.

Testing Spatial Autocorrelation

33

Page 34: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Visual inspection of the kernel shape g(y|Wy) allows to observe if spatial patterns

are strong or weak.

If probability density flows along the main diagonal it means y would have had similar

values even if it have had different neighborโ€™s (space not relevant)

If probability density flows in paralallel to the y axis it means spatial effects are

important drivers of the observed distribution of y. (space is relevant)

Testing Spatial Autocorrelation

34

Page 35: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Moranโ€™s I calculation (example of Kosfeld lecture notes)

Assume we have the following spatial arrangement of units:

and the following geo-referenced variable

Testing Spatial Autocorrelation

35

Unemployment

Region 1 8

Region 2 6

Region 3 6

Region 4 3

Region 5 2

Page 36: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

The spatial scheme:

can be represented by the following 5 x 5 contiguity matrix:

๐‘Š =

0 1 1 0 01 0 1 1 0100

110

010

101

010

We will work first with the non-standardized W

Testing Spatial Autocorrelation

36

Page 37: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐ผ =๐‘›ฯƒ๐‘–=1

๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–๐‘› ๐‘ค๐‘–๐‘—

โˆ— (๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

๐‘† ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

Table 1: Cross products (๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

Testing Spatial Autocorrelation

37

UR

Region 1 8

Region 2 6

Region 3 6

Region 4 3

Region 5 2

Avg 5

Page 38: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Unstandardized weights

Table 2: Unstandardized weights (๐‘ค๐‘–๐‘—โˆ— )

Testing Spatial Autocorrelation

38

Page 39: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Table 3: weighted cross products: ฯƒ๐‘–=1๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–

๐‘› ๐‘ค๐‘–๐‘—โˆ— (๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

Testing Spatial Autocorrelation

39

Page 40: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Table 4: Sum of squared deviations ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

Moranโ€™s I (unstandardized weight matrix):

๐ผ =๐‘›

๐‘†

๐‘งโ€ฒ๐‘Š๐‘ง

๐‘งโ€ฒ๐‘ง=

5

12

18

24= 0.3125

Testing Spatial Autocorrelation

40

Page 41: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Opening Matlab you can reproduce these tedious calculations by

typing:

n=length(x);

xm=mean(x);

xmv=ones(n,1)*xm;

cprod1 = (x-xmv)'*W*(x-xmv); % this is Table 3

xsqr=(x-xmv)'*(x-xmv); % this is Table 4 (part of the denominator)

Wv=vec(W,2);

S=sum(Wv); %needed for the calculation of the numerator

I = [n/S]*[cprod1/xsqr]; % this is the Moranโ€™s I value

res.I = I;

Testing Spatial Autocorrelation

41

Page 42: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Calculation of Moranโ€™s I with standardized weight matrix:

๐ผ =ฯƒ๐‘–=1๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–

๐‘› ๐‘ค๐‘–๐‘—(๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

The cross-products are the same as in our previous case: (๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

Testing Spatial Autocorrelation

42

Page 43: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

The row-normalized W, however, is different:

Table 5: Standardized weights ๐‘ค๐‘–๐‘—

Table 6: Weighted cross-products๐‘ค๐‘–๐‘—(๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

Testing Spatial Autocorrelation

43

Page 44: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Again, the sum of squared deviations is ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2 = 24

Thus, the Moranโ€™s I (for the standardized W) is slightly higher:

๐ผ =ฯƒ๐‘–=1๐‘› ฯƒ๐‘—=1,๐‘—โ‰ ๐‘–

๐‘› ๐‘ค๐‘–๐‘— (๐‘ฅ๐‘– โˆ’ าง๐‘ฅ)(๐‘ฅ๐‘— โˆ’ าง๐‘ฅ)

ฯƒ๐‘–=1๐‘› ๐‘ฅ๐‘– โˆ’ าง๐‘ฅ 2

=11

24= 0.4583

Check in Matlab that by inputing the standardized W you actually

get this value.

This was the standardized W matrix

Testing Spatial Autocorrelation

44

Page 45: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Moranโ€™s I statistical significance

To analyze significance of the observed spatial correlated pattern we need a Z statistic that allows

us to calculate p-values

It is given by:

๐‘ ๐ผ =๐ผ โˆ’ ๐ธ(๐ผ)

๐‘‰๐ด๐‘…(๐ผ)~๐‘(0,1)

Expected value ๐ธ ๐ผ = โˆ’1

๐‘›โˆ’1

Variance of I (normal aprox)

๐‘‰๐ด๐‘… ๐ผ =๐‘›2๐‘†1+๐‘›๐‘†2+3๐‘†0

2

(๐‘›โˆ’1)๐‘†02 โˆ’ ๐ธ(๐ผ) 2

where:

๐‘†0 =

๐‘–=1

๐‘›

๐‘—=1

๐‘›

๐‘ค๐‘–๐‘— ; ๐‘†1 =1

2

๐‘–=1

๐‘›

๐‘—=1

๐‘›

(๐‘ค๐‘–๐‘— + ๐‘ค๐‘—๐‘–)2 ;

๐‘†2 =

๐‘–=1

๐‘›

๐‘—=1

๐‘›

๐‘ค๐‘–๐‘— +

๐‘—=1

๐‘›

๐‘ค๐‘—๐‘–

2

Testing Spatial Autocorrelation

45

Page 46: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

In the example of 5 regions (n=5) we have calculated a value of Moranโ€™s I of

0.4583 on the basis of the standardized weight matrix

Despite the small sample, we use the proportional approximation of the significance

of the Moranโ€™s I test for illustrative purposes.

Expected value ๐ธ ๐ผ = โˆ’1

๐‘›โˆ’1= โˆ’0.25

๐‘†0 =

๐‘–=1

๐‘›

๐‘—=1

๐‘›

๐‘ค๐‘–๐‘— = 5

Testing Spatial Autocorrelation

46

Page 47: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐‘†1 =1

2

๐‘–=1

๐‘›

๐‘—=1

๐‘›

๐‘ค๐‘–๐‘— +๐‘ค๐‘—๐‘–2

= [ ๐‘ค12 + ๐‘ค212 + ๐‘ค13 +๐‘ค31

2 + ๐‘ค14 +๐‘ค412 + ๐‘ค15 +๐‘ค51

2

+ ๐‘ค21 +๐‘ค122 + ๐‘ค23 +๐‘ค32

2 + ๐‘ค24 +๐‘ค422 + ๐‘ค25 +๐‘ค52

2

+ ๐‘ค31 +๐‘ค132 + ๐‘ค32 +๐‘ค23

2 + ๐‘ค34 +๐‘ค432 + ๐‘ค35 +๐‘ค53

2

+ ๐‘ค41 +๐‘ค142 + ๐‘ค42 +๐‘ค24

2 + ๐‘ค43 +๐‘ค342 + ๐‘ค45 +๐‘ค54

2

+ ๐‘ค51 +๐‘ค152 + ๐‘ค52 + ๐‘ค25

2 + ๐‘ค53 + ๐‘ค352 + ๐‘ค54 + ๐‘ค45

2

= [ ๐‘ค12 + ๐‘ค212 + ๐‘ค13 +๐‘ค31

2 + ๐‘ค14 +๐‘ค412 + ๐‘ค15 +๐‘ค51

2

+ ๐‘ค21 +๐‘ค122 + ๐‘ค23 +๐‘ค32

2 + ๐‘ค24 +๐‘ค422 + ๐‘ค25 +๐‘ค52

2

+ ๐‘ค31 +๐‘ค132 + ๐‘ค32 +๐‘ค23

2 + ๐‘ค34 +๐‘ค432 + ๐‘ค35 +๐‘ค53

2

+ ๐‘ค41 +๐‘ค142 + ๐‘ค42 +๐‘ค24

2 + ๐‘ค43 +๐‘ค342 + ๐‘ค45 +๐‘ค54

2

+ ๐‘ค51 +๐‘ค152 + ๐‘ค52 + ๐‘ค25

2 + ๐‘ค53 + ๐‘ค352 + ๐‘ค54 + ๐‘ค45

2

= ๐‘ค12 +๐‘ค212 + ๐‘ค13 + ๐‘ค31

2 + ๐‘ค21 +๐‘ค122 + ๐‘ค23 +๐‘ค32

2 + ๐‘ค24 +๐‘ค422 +

๐‘ค31 + ๐‘ค132 + ๐‘ค32 + ๐‘ค23

2 + ๐‘ค34 + ๐‘ค432 + ๐‘ค42 + ๐‘ค24

2 + ๐‘ค43 + ๐‘ค342 +

๐‘ค45 + ๐‘ค542 + ๐‘ค54 + ๐‘ค45

2

Testing Spatial Autocorrelation

47

Page 48: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

= ๐‘ค12 +๐‘ค212 + ๐‘ค13 +๐‘ค31

2 + ๐‘ค21 + ๐‘ค122 + ๐‘ค23 +๐‘ค32

2

+ ๐‘ค24 + ๐‘ค422 + ๐‘ค31 + ๐‘ค13

2 + ๐‘ค32 + ๐‘ค232 + ๐‘ค34 + ๐‘ค43

2

+ ๐‘ค42 + ๐‘ค242 + ๐‘ค43 + ๐‘ค34

2 + ๐‘ค45 + ๐‘ค542 + ๐‘ค54 + ๐‘ค45

2

Recall that the standardized W is given by:

=1

2+1

3

2

+1

2+1

3

2

+1

3+1

2

2

+1

3+1

3

2

+1

3+1

3

2

+1

3+1

2

2

+1

3+1

3

2

+1

3+1

3

2

+1

3+1

3

2

+1

3+1

3

2

+1

3+ 1

2

= 4.5

Testing Spatial Autocorrelation

48

Page 49: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

๐‘†2 =

๐‘–=1

๐‘›

๐‘–=1

๐‘›

๐‘ค๐‘–๐‘— +

๐‘–=1

๐‘›

๐‘ค๐‘—๐‘–

2

=

๐‘–=1

๐‘›

๐‘ค๐‘–โˆ— + ๐‘คโˆ—๐‘–2

๐‘–=1

๐‘›

๐‘ค๐‘–โˆ— +๐‘คโˆ—๐‘–2 =

= ๐‘ค1โˆ— + ๐‘คโˆ—12 + ๐‘ค2โˆ— + ๐‘คโˆ—2

2 + ๐‘ค3โˆ— + ๐‘คโˆ—32 + ๐‘ค4โˆ— + ๐‘คโˆ—4

2 + ๐‘ค5โˆ— + ๐‘คโˆ—52

= 1.16

Suming up we have:

โ€ข ๐‘†0 = 5

โ€ข ๐‘†1 = 4.5

โ€ข ๐‘†2 =21

18= 1.16

โ€ข ๐‘‰๐ด๐‘… ๐ผ =๐‘›2๐‘†1+๐‘›๐‘†2+3๐‘†0

2

(๐‘›โˆ’1)๐‘†02 โˆ’ ๐ธ ๐ผ

2= 0.0745

โ€ข ๐‘ ๐ผ = 2.5955 โ†’ ๐‘ = 0.0095

Testing Spatial Autocorrelation

49

Page 50: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

MATLAB code for the test on the statistical significance of the Moranโ€™s I

EI=-(1./(n-1)); % expected value

S0=S; s1=zeros(n,n);

for i =1:n % loop over i

for j =1:n % loop over j

s1(i,j) = (W(i,j) + W(j,i)).^2;

end

end

s1v=vec(s1,2); S1=0.5*sum(s1v); %vectorize s1 and sum

s2=zeros(n,1);

for i= 1:n

s2(i) =([sum(W(i,:))+ sum(W(:,i))].^2);

end

S2=sum(s2);

NumVarI=(n^2)*S1-n*S2 + 3.*(S0).^2; DenVarI=(n^2-1)*(S0).^2;

VARI=(NumVarI./DenVarI)-EI^2;

Z=(I-EI)./(sqrt(VARI)); prob = norm_prb(Z);

Testing Spatial Autocorrelation

50

Page 51: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Testing Spatial Autocorrelation

51

Page 52: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

If you copy previous sequence of code to calculate Moranโ€™s I and to

calculate its significance in the Matlab editor and save it as a

function, each time you provide the function a variable x and a W

matrix, Matlab will calculate for you the corresponding values.

Testing Spatial Autocorrelation

52

Page 53: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Moran scatterplot (5 regions)

Testing Spatial Autocorrelation

53

Page 54: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

The Moranโ€™s scatterplot is a special form of a bivariate scatterplot which

makes use of the standardized values of the pairs (X,WX)

Augmented with the regression line it can be used to asses to the degree of

fit and to identify outliers

Table: Types of local spatial association

Positive spatial association: HH and LL

Negative spatial association: LH and HL (spatial outliers in case of + spatial

autocorrelation

Testing Spatial Autocorrelation

54

Spatially lagged geo-referenced variable

(WX)

High Low

Geo-referenced

variable (X)

High Quadrant I (HH) Quadrant IV(HL)

Low Quadrant II (LH) Quadrant III (LL)

Page 55: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Goals

Draw a Moranโ€™s Scatterplot using of the unemployment rate in

European regions using the W matrices created previously. We will use

the 5-nearest neighbors and the exponential with cut-off at the first

quartile.

Run a OLS regression of X (unemployment rates) and WX (the

spatial lag of unemployment rates) using the two matrices with the

variables expressed in deviations with respect the sample average (or

use the originals with a constant)

Check the slopes obtained in the regression with the results of the

MoranI.m function we have coded. Is the Moranโ€™s I statistically

significant at the 5% level ?

Practice (Global Spatial Autocorrelation)

55

Page 56: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Switch to Matlabโ€œTutorial2_Global_Spat_Autocorr.mโ€

56

Page 57: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Matlab functions

MoranI.m โ†’ function that calculates Moranโ€™s I statistic and its

significance level

OLS_demo.m โ†’ function to perform basic OLS regression

prt.m โ†’ prints the results into the command window of a regression

structure results.

Practice (Part Global Spatial Autocorr)

57

Page 58: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Global Spatial Autocorr)

58

Page 59: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Moranโ€™s scatterplot of unemployment rates in European NUTS-2

regions

Practice (Part Global Spatial Autocorr)

59

Page 60: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Global Spatial Autocorr)

60

Page 61: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Global Spatial Autocorr)

61

Page 62: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Main message: spatial correlation is NOT universal like time

correlation. Depends on our defenition of space and interdependence.

Finding the true W is of key importance to model real spatial associations

Practice (Part Global Spatial Autocorr)

62

Page 63: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Global spatial correlation summarizes the strength of spatial

dependencies by a single statistic.

LISA focuses on heterogeneity of spatial association over space.

LISA provide detailed information of spatial clustering.

LISA for each observation tells how values around that observation are

clustered.

Useful for detecting local clusters and spatial outliers.

A local cluster is characterized by a concentration of high values of an

attribute variable X. A spatial clustering of high value contiguous

region is called hot spot whereas a spatial clustering of low value

contiguous regions is called cold spot.

Spatial outliers are regions with reversed orientation compared to the

predominant global one

Local Indicators of Spatial Association (LISA)

63

Page 64: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

We deal with one of two may well-known LISA:

The Local Moranโ€™s I statistic

Useful for detecting spatial outliers and general clustering

formations (we focus on this one)

The Getis-Ord G statistic

Better suited for identifying specific cluster formations

Local Indicators of Spatial Association (LISA)

64

Page 65: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Local Moran statistic I(i) detects local spatial autocorrelation. The I(i)โ€™s are

indicators of local instability. They decompose the Moranโ€™s I into contributions for

each location.

According to this property, Local Moranโ€™s I can be used for two purposes:

Indicators of local spatial clusters

Diagnostics for outliers in global spatial patterns

Local Moranโ€™s I statistic:

๐ผ๐‘– =(๐‘ฅ๐‘–โˆ’ าง๐‘ฅ) ฯƒ๐‘—=1

๐‘› ๐‘ค๐‘–๐‘— ๐‘ฅ๐‘—โˆ’ าง๐‘ฅ

1

๐‘›ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘—โˆ’ าง๐‘ฅ

2

Numerator: determines the sign of I(i)

+ if both the i-th region and neighbors have above or below average values in the geo-

referenced variable X and

(-) if the i-th region as an above(below) neighboring regions have a below(above) average

values of X

Denominator: standardization of the cross-product by the variance of the georeferenced

variable X

Local Indicators of Spatial Association (LISA)

65

Page 66: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Below is a plot of Local Moran Z-scores for the 2004 Presidential

Elections. Higher absolute values of z scores (red) indicate the presence of

hot spots", where the percentage of the vote received by President Bush was

significantly different from that in neighboring counties.

Testing Spatial Autocorrelation

66

Page 67: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Example of Local Moranโ€™s I:

We calculate Local Moran statistics with the standardized weights wij:

The sum of squared deviations from the mean has already been calculated with

the Moranโ€™s I:

1/๐‘›

๐‘—=1

๐‘›

๐‘ฅ๐‘— โˆ’ าง๐‘ฅ2= 4.8

This will be our denominator in the following calculations

Local Indicators of Spatial Association (LISA)

67

Page 68: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Region 1

๐ผ1 =(๐‘ฅ1 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค1๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

= 0.625

๐‘—=1

๐‘›

๐‘ค1๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ =1

26 โˆ’ 5 +

1

26 โˆ’ 5 = 1

๐‘ฅ1 โˆ’ าง๐‘ฅ = 8 โˆ’ 5

So:

๐ผ1 =(๐‘ฅ1 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค1๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

=(3)(1)

4.8= 0.625

Local Indicators of Spatial Association (LISA)

68

Page 69: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Region 2

๐ผ2 =(๐‘ฅ2 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค2๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

= 0.1389

๐‘—=1

๐‘›

๐‘ค2๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ =1

38 โˆ’ 5 +

1

36 โˆ’ 5 +

1

33 โˆ’ 5 =

2

3

๐‘ฅ2 โˆ’ าง๐‘ฅ = 6 โˆ’ 5 = 1

So:

๐ผ2 =(๐‘ฅ2 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค2๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

=1 (

23)

4.8= 0.1389

Local Indicators of Spatial Association (LISA)

69

Page 70: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Region 3

๐ผ3 =(๐‘ฅ3 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค3๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

= 0.1389

๐‘—=1

๐‘›

๐‘ค3๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ =1

38 โˆ’ 5 +

1

36 โˆ’ 5 +

1

33 โˆ’ 5 =

2

3

๐‘ฅ3 โˆ’ าง๐‘ฅ = 6 โˆ’ 5 = 1

So:

๐ผ3 =(๐‘ฅ3 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค3๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

=1 (

23)

4.8= 0.1389

Local Indicators of Spatial Association (LISA)

70

Page 71: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Region 4

๐ผ4 =(๐‘ฅ4 โˆ’ าง๐‘ฅ) ฯƒ๐‘—=1

๐‘› ๐‘ค4๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

= 0.1389

๐‘—=1

๐‘›

๐‘ค4๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ =1

36 โˆ’ 5 +

1

36 โˆ’ 5 +

1

32 โˆ’ 5 = โˆ’

1

3

๐‘ฅ4 โˆ’ าง๐‘ฅ = 3 โˆ’ 5 = โˆ’2

So:

๐ผ4 =(๐‘ฅ4 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค4๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

=(โˆ’2)(โˆ’

13)

4.8= 0.1389

Local Indicators of Spatial Association (LISA)

71

Page 72: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Region 5

๐ผ5 =(๐‘ฅ5 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค5๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

= 1.25

๐‘—=1

๐‘›

๐‘ค5๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ = 1 3 โˆ’ 5 = โˆ’2

๐‘ฅ5 โˆ’ าง๐‘ฅ = 2 โˆ’ 5 = โˆ’3

So:

๐ผ5 =(๐‘ฅ5 โˆ’ าง๐‘ฅ)ฯƒ๐‘—=1

๐‘› ๐‘ค5๐‘— ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

ฯƒ๐‘—=1๐‘› ๐‘ฅ๐‘— โˆ’ าง๐‘ฅ

2/๐‘›

=(โˆ’2)(โˆ’3)

4.8= 1.25

Local Indicators of Spatial Association (LISA)

72

Page 73: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Does the average of local Moranโ€™s I produce the global Moranโ€™s I calculated

before?

Recall that from our previous example with standardized weights we have:

I = 0.4583

๐ผ =1

5

๐‘–

5

๐ผ๐‘– =1

50.625 + 0.1389 + 0.1389 + 0.1390 + 1.25 = 0.4583

Interpretation of the results in this example:

- A local spatial cluster is identified around region 5 and to somewhat les

around region 1, as both, ๐ผ5 and ๐ผ1 exceed the global Moranโ€™s I noticeably

- Since all ๐ผ๐‘– values exceed their expected value, no outlying region with

respect to the orientation is identififed

Local Indicators of Spatial Association (LISA)

73

Page 74: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Goals

Estimate Local Moranโ€™s I using unemployment rates in European

regions using the exponential with cut-off at the third quartile W

matrix. Use the function โ€œlocalMoranI.mโ€

Check that the average of the Local Moran Iโ€™s add up to the global

Moran I (you need to calculate the global Moran for these Ws)

Create a scatterplot of the estimated Local Moran Iโ€™s and another of its

estimated p-values. Is there any pattern?

Create one map of the estimated Local Moranโ€™s I and another one of

the estimated p-values

Practice (Part Local Spatial Autocorr)

74

Page 75: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Switch to Matlabโ€œTutorial3_Local_Spat_Autocorr.mโ€

75

Page 76: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Local Spatial Autocorr)

76

You should obtain a global Moranโ€™s I of 0.8797 and that the average over

Local Moranโ€™s I is also 0.8797

Page 77: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Local Moranโ€™s I Map

Practice (Part Local Spatial Autocorr)

77

Local cluster of high

unemployment rates

Page 78: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Some simplified insights in the south-of Spain local cluster of

unemployment:

(1) Low-valued addded specialization in agriculture (olive oil) dependent on

subsidies and strong public-sector employment share (non-market services)

(2) Distribution of land and income, highly unequal (due to historical reasons)

(1) + (2) โ†’ dependent population

(3) Socialist Party stronghold โ†’ Monopoly of political power

(4) High levels of corruption

(3) + (4) โ†’ clientelistic regime

(5) High levels of religiosity โ†’ traditional values and few entrepreneurship

(6) High levels of luminosity + nice weather โ†’ strong amenity

All together: corrupt regime with dependent population that does not migrate

to other region (there is not regional re-balancing of the labor supply)

Practice (Part Local Spatial Autocorr)

78

Page 79: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Local Spatial Autocorr)

79

Page 80: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Local Spatial Autocorr)

80

Page 81: Spatial and Regional Economic Analysis Mini-Course

Vicente Rios

Practice (Part Local Spatial Autocorr)

81