Lecture 7: Spatial Econometric Modeling of Origin-Destination Flows

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Lecture 7: Spatial Econometric

Modeling of Origin-Destination flows


James P. LeSage
Department of Economics
University of Toledo
Toledo, Ohio 43606
e-mail: jlesage@spatial-econometrics.com

June 2005
The gravity/spatial interaction model

• The terms ’gravity models’ and ‘spatial interaction


models’ has been used in the literature to label models
that focus on flows between origins and destinations, Sen
and Smith (1995).
• These typical rely on a function of the distance between
an origin and destination and explanatory variables
pertaining to characteristics of both origin and destination
regions.
• With a few exceptions, use of spatial lags typically found
in spatial econometric methods have not been used in
these models.
• The notion that use of distance functions in conventional
spatial interaction models effectively capture spatial
dependence in the interregional flows being analyzed has
been challenged in recent work by Porojon (2001) for the
case of international trade flows, Ming and Pace (2004)
for retail sales and unpublished work that utilizes both
German and Canadian transportation network flows.
• The residuals from conventional models were found to
exhibit spatial dependence, which could be exploited to
improve the precision of inference as well as prediction
accuracy.

1
Interregional flows in a spatial regression
context

• Starting with an n by n square matrix of interregional


flows from each of the n origin regions to each of the n
destination regions, we can produce an n2 by 1 vector of
these flows by stacking the columns of the flow matrix
into a variable vector that we designate as y .

Table 1: A flow matrix (population migration 1995-2000)


Destination/Origin Origin 1 Origin 2 ... Origin n
Alabama Arizona Wyoming
Destination 1 (Alabama) 1,392,507 2,797 467
Destination 2 (Arizona) 3,452 1,669,415 4,458
..
.
Destination n (Wyoming) 517 2,246 147,232

• A typical least-squares gravity model

y = αι + Xdβd + Xoβo + Dγ + ε (1)

where:

2
0 1
x1
B x1 C
B C
B ... C
B C
B x1 C
B C
0 1 B x2 C
B C
X(nxk) B C
B X(nxk) C B x2 C
B ... C
Xd = B
@ ... C
A Xo = B C (2)
B C
B x2 C
X(nxk) B C
B ... C
B C
B xn C
B C
B xn C
B ... C
@ A
xn

• D is a matrix of O-D distances vectorized (n2x1)


• ι is an n2x1 intercept vector
• ε ∼ N (0, σ 2In2 )
• α, βo, βd, γ are parameters to be estimated

3
Spatial dependence of flows

• In contrast to the traditional regression-based gravity


model, a spatial econometric model of the variation in
origin-destination flows would be characterized by:
1) reliance on spatial lags of the dependent variable
vector, which we refer to as a spatial autoregressive
model (SAR):
y = ρW y + Xβ + ε, or
2) of the disturbance terms, which we label a spatial
error model (SEM):
y = Xβ + u, u = ρW u + ε, or
3) perhaps spatial lags of both kinds, which we denote
as the general spatial model (SAC):
y = ρW y + Xβ + u u = ρW u + ε.
• Spatial weight matrices represent a convenient and
parsimonious way to define the spatial dependence or
connectivity relations among observations.

4
Spatial weight matrices for flows
• A key issue is how to construct a meaningful spatial
weight matrix in the case where the n2 by 1 vector
of observations reflect flows from all origins to all
destinations, rather than the typical case where each
observation represents a region.
• We can create a typical n by n first-order contiguity
or m nearest neighbors weight matrix W that reflects
relations between the n destinations/origin regions. This
can be repeated using In ⊗ W to create an n2 by n2
row-standardized spatial weight matrix that we label Wo,
shown in (3).
0 1
W 0 ... 0
B 0 W 0 ... C
Wo = B @ ...
C (3)
0 . . . 0 A
0 ... 0 W
• Use of this matrix to form a spatial lag of the dependent
variable, Woy , (where Wo = In ⊗ W with W row-
standardized), we can capture “origin-based” spatial
dependence relations using an average of flows from
neighbors to each origin state to each of the destinations.
• Intuitively, it seems plausible that forces leading to flows
from any origin to a particular destination state may
create similar flows from neighbors to this origin to the
same destination. This is what the spatial lag Woy
captures.

5
An example of “origin-based” spatial
dependence

• As an example, consider a single row i of the spatial lag


vector Woy that represents flows from the origin state
of Florida to the destination state of Washington. If
the states are organized by FIPS code, or alphabetically
(excluding Alaska and Hawaii) this would be the (45 x
49 + 9)th row, since Washington is the 45th state and
Florida is the 9th state.
• First-order contiguous neighbors to the origin Florida are
Alabama and Georgia, and neighbors to the destination
Washington are Oregon and Idaho. The spatial lag Woy
would represent an average of the flows from Alabama
and Georgia (neighbors to the origin) to the destination
state Washington.
• A similar interpretation applies to other rows of the spatial
lag Woy , for example the (45 x 49 + 1)st row represents
flows from the origin state of Alabama to the destination
state of Washington, since Washington is the 45th state
and Alabama is the 1st state.
• In this case, spatial lag Woy would represent an average
of the flows from Florida, Georgia, Mississippi and
Tennessee (neighbors to the origin) to the destination
state Washington.

6
“Destination-based” spatial dependence

• A second type of spatial dependence that could arise


in the gravity model would be “destination-based”
dependence. Intuitively, it seems plausible that forces
leading to flows from an origin state to a destination
state may create similar flows to nearby or neighboring
destinations.
• A spatial weight matrix that we label Wd can be
constructed to capture this type of dependence using
W ⊗ In, producing an n2 by n2 spatial weight matrix
that captures connectivity relations between the flows
from an origin state to neighbors of the destination state.
• Using our example of flows from the origin state of
Florida to the destination state of Washington, the (45 x
49 + 9)th row of the spatial lag vector Wdy represent an
average of flows from Florida to Idaho and Oregon, states
that neighbor the destination state of Washington. In
our other example, where the origin state was Alabama,
the (45 x 49 + 1)st row of the spatial lag vector Wdy
would represent an average of flows from Alabama to
Idaho and Oregon, states that neighbor the destination
state of Washington.

7
An example of “destination-based” spatial
dependence
• To provide an example of this we consider four regions
located in a row as presented in Table 2.

Table 2: Location of 4 Regions in Space


Region #1 Region #2 Region #3 Region #4

• The row-standardized first-order contiguity matrix


associated with this regional configuration is shown in
(4).
0 1
0 1 0 0
B 1/2 0 1/2 0 C
W =@ B C (4)
0 1/2 0 1/2 A
0 0 1 0
• For this example, Wd = W ⊗ In taking the form shown
in (5), where the n by n matrix W is defined in (5) and
0 represents an n by n matrix of zeros, where n = 4 in
this example.

0 1
0 In 0 0
B (1/2)In 0 (1/2)In 0 C
Wd = B
@
C
0 (1/2)In 0 (1/2)In A
0 0 In 0
(5)

8
“Origin-destination-based” spatial
dependence

• A third type of dependence to consider is reflected in the


product Wo · Wd = (In ⊗ W ) · (W ⊗ In) = W ⊗ W .
• This spatial weight matrix reflects an average of flows
from neighbors to the origin state to neighbors of the
destination state.
• One motivation for this matrix product might be a
spatial filtering perspective. We might envision a spatial
autoregressive model of the type shown in (6) based on
successive filtering.

(In2 −ρ1Wo)(In2 −ρ2Wd)y = αι+Xdβd+Xoβo+Dγ+ε


(6)
• This leads to a model that includes the interaction term
in the sequence of spatial lags:

y = ρ1 W o y + ρ2 W d y − ρ1 ρ2 W o W d y
+ αι + Xdβd + Xoβo + Dγ + ε (7)

9
An example of “origin-destination-based”
spatial dependence

• Using our example of flows from the origin state of Florida


to the destination state of Washington, the (45 x 49 +
9)th row of the spatial lag vector WoWdy represent an
average of: flows from Alabama and Georgia (neighbors
to the origin state) to Idaho (a neighbor to the destination
state), and flows from Alabama and Georgia (neighbors to
the origin state) to Oregon (a neighbor to the destination
state).
• In the case of our other example based on flows from
the origin state of Alabama to the destination state of
Washington, the (45 x 49 + 1)st row of the spatial
lag vector WoWdy represent an average of: flows from
Florida, Georgia, Mississippi and Tennessee (neighbors to
the origin state) to Idaho (a neighbor to the destination
state) and flows from Florida, Georgia, Mississippi and
Tennessee (neighbors to the origin state) to Oregon (a
neighbor to the destination state).

10
Spatial regression models for O-D flows

• Proposition #1
– Given a row-normalized spatial weight matrix W , the
spatial weight matrices:

Wo = In ⊗ W (8)
Wd = W ⊗ In
Wod = W ⊗W

can be used directly to extend the gravity regression


model in (1) to a SAR, SEM or SAC model
specification as shown in (9).

y = ρWJ y + αι + Xdβd + Xoβo + Dγ + u


u = λWJ u + ε (9)

where: WJ denotes any of the spatial weight matrices


Wo, Wd, Wod.
– The spatial weight matrices Wo, Wd, Wod would obey
the usual properties of row-normalized weight matrices
allowing use of existing algorithms for maximum
likelihood (Pace and Barry, 1997), Bayesian (LeSage,
1997) or generalized method of moments estimation
estimation (Kelejian and Prucha, 1999).

11
• Proposition #2
– Given a row-normalized spatial weight matrix W , the
elements of the matrices Wo and Wd are mutually
exclusive. This allows us to add the spatial weight
matrices:

WJ = Wo + Wd (10)
= (In ⊗ W ) + (W ⊗ In)

and use this summation directly to extend the gravity


regression model in (1) to a SAR, SEM or SAC model
specification as shown in (9).
– The sum of weight matrices reflecting “destination”
and “origin” dependence spatial weight matrices
Wo, Wd would obey the usual properties of row-
normalized weight matrices allowing use of existing
algorithms for maximum likelihood (Pace and Barry,
1997), Bayesian (LeSage, 1997) or generalized method
of moments estimation estimation (Kelejian and
Prucha, 1999).

12
• Proposition #3
– Given a row-normalized spatial weight matrix W , one
can form a spatial weight matrix:

WJ = Wo + Wd + Wod (11)
= (In ⊗ W ) + (W ⊗ In) + (W ⊗ W )

– This captures ‘origin’, ’destination’, as well as ’origin-


destination interaction’ dependence.
– This weight matrix would obey the usual properties
of row-normalized weight matrices allowing use of
existing algorithms for maximum likelihood (Pace and
Barry, 1997), Bayesian (LeSage, 1997) or generalized
method of moments estimation estimation (Kelejian
and Prucha, 1999).

13
Non-conventional model specifications

• In addition to model specifications that can be estimated


using conventional algorithms, there are a series
of specifications that require slight changes to the
conventional algorithms.
• For example, a successive spatial filtering approach
suggests the specification:

(In2 −ρ1Wo)(In2 −ρ2Wd)y = αι+Xdβd+Xoβo+Dγ+ε


(12)
• This leads to a model that includes the interaction term
in the sequence of spatial lags:

y = ρ1 W o y + ρ2 W d y − ρ1 ρ2 W o W d y
+ αι + Xdβd + Xoβo + Dγ + ε (13)

• Note that WoWd = W ⊗ W , and we can relax the


restriction from (13) that ρ3 = ρ1ρ2 using:

y = ρ1 W o y + ρ2 W d y − ρ3 W o W d y
+ αι + Xdβd + Xoβo + Dγ + ε (14)

14
Maximum likelihood estimation

• Despite the statements made here regarding use


of conventional algorithms for maximum likelihood,
Bayesian or generalized method of moments estimation
of the spatial econometric origin-destination interregional
flow models, there are some computational considerations
that arise as the number of observations becomes large.
• For example, use of an origin-destination flow matrix
for the over 3,100 US counties would result in sparse
spatial weight matrices of dimension n2 by n2 where
n2 = 9, 610, 000.
• Maximum likelihood and Bayesian estimation both
require calculation of the log of the determinant
expression for the n2 by n2 matrix: (In2 − ρWJ ).
• While specialized approaches to calculating this log-
determinant have been proposed by Pace and LeSage
(2004) and Anselin and Smirnov (2004), it turns out
there are much more efficient approaches that can exploit
the special structure of matrices like Wd = In ⊗ W ,
Wo = W ⊗ In and Ww = W ⊗ W .

15
The log-determinant term in the likelihood

• We note that the likelihood function for models based


on a single spatial weight matrix WJ , concentrated with
respect to the parameters β and σ will take the form:

2 0
LogL(ρ) = C +log|In2 −ρWJ |−(n /2)log(e e(ρ))
(15)
Where e0e(ρ) represents the sum of squared errors
expressed as a function of the scalar parameter ρ alone
after concentrating out the parameters β, σ (see LeSage
and Pace, 2004).
• The log-determinant of the transformation is the trace
of the matrix logarithm of the transformation, and the
Taylor series expansion of this has a simple form for the
positive definite matrix transformation In2 − ρWJ .

ln |In2 − ρWJ | = tr (ln(In2 − ρWJ ))


X

ρttr(WJt )
= − (16)
t=1
t

16
• For the case of destination or origin weight matrices,
Wd = In ⊗ W or Wo = W ⊗ In, which we designate
WJ , J = o, d

t t t t t
tr(WJ ) = tr(In ⊗ W ) = tr(In) · tr(W )
t
= n · tr(W ) (17)

and thus the trace of a square matrix of order n2 is


simplified to a scalar (n) time a trace of a square matrix
of order n (i.e., W ).
• This means we can handle the US county sample
containing n2 = 9, 610, 000 observations in the same
time as the n = 3, 100 problem, or around 1-2 seconds.

17
Successive spatial filtering model
specifications

• As noted earlier, a possible variant of using either an


origin weight matrix Wo or a destination weight matrix
Wd would be to successively transform the dependent
variable by (In2 − ρ1Wo) and (In2 − ρ2Wd).
• The idea would be to remove the destination dependence
and subsequently remove the origin dependence or vice-
versa.
• Remarkably, the order in which one transforms the
dependent variable makes no difference as stated in (18).

(In2 − ρ1Wo)) · (In2 − ρ2Wd)) = (18)


(In2 − ρ2(In ⊗ W )) (In2 − ρ1(W ⊗ In))

• The explanation for this can be seen by expanding the


products in (19). Since the cross-product of W ⊗ In and
In ⊗ W is W ⊗ W , and this is the same as the cross-
product of In ⊗ W and W ⊗ I via the mixed-product
rule for Kronecker products.

(In2 − ρ1Wd)) · (In2 − ρ2Wo) = (19)


(In2 − ρ1(W ⊗ In) − ρ2(In ⊗ W ) + ρ1ρ2(W ⊗ W ))

18
• Because the log-determinant of a product is the sum of
the log-determinants, the overall log-determinant of the
successive filtering approach is quite simple as shown in
(20).

ln |(In2 − ρ1Wd) (In2 − ρ2Wo)| =


n(ln |In − ρ1W | + ln |In − ρ2W |) (20)

• This suggests we can specify a general form based on:

WJ = ρ1(W ⊗In)+ρ2(In ⊗W )+ρ3(W ⊗W ) (21)

• This general specification can yield a number of specific


models of interest.
– Obviously, when ρ1 = ρ2 = ρ3 = 0 no spatial
autoregressive dependence exists.
– When ρ2 = ρ3 = 0 the model becomes one of origin
autoregressive spatial dependence.
– When ρ1 = ρ3 = 0 the model becomes one of
destination autoregressive spatial dependence.
– When ρ3 = −ρ1ρ2 the successive filtering or product
separable model emerges.
– Finally, the restriction ρ3 = 0 produces the joint
origin destination autoregressive dependence model

19
The log-determinant term for successive
spatial filtering model specifications

• The challenge is to easily compute tr(WJt ) for t =


1 · · · m where m is the largest moment computed.
• In brief, by combining an approach set forth by Barry and
Pace (1999) for a statistical Monte Carlo approximation
to the log-determinant and some results from Pace and
LeSage (2002, Geographical Analysis), Kelley and I have
implemented a MATLAB function to compute the log-
determinant term for these models.
• Our approach is a statistical approximation, but using
results from Pace and LeSage (2002) where we show how
the moments tr(WJt ) must monotonically decline for
t > 1, we can provide an estimate of the confidence
intervals for the accuracy of our approximation and
show that the interval is narrow provided (ρ1 + ρ2 +
ρ3)m+1/(m + 1) is reasonably small.

20
Some applied illustrations

• Using population migration flows over the periods 1985-


90 and 1995-2000 for the 48 contiguous US states plus
the District of Columbia, n = 49, n2 = 2401, a small
example.
• Dependent variable y is the growth rate in interstate
migration flows from the earlier to later period, intrastate
flows are set to zero.
• Explanatory variables are origin and destination
characteristics for the states in 1990 taken from the
1990 US Census. All variables are log transformed.
– State area
– State per capita income, retirement income
– # of males, # of females (sum = population)
– (# persons aged 22-29) young, (# persons aged 60-
64) near retirement, (# persons aged 65 plus) retired
– # persons born in the state, # persons foreign born,
# recent foreign immigrants
– # of college graduates, # of persons with graduate
and professional degrees
– median house value, median rent
– travel time to work
– # persons unemployed, # persons self-employed
– log(distance) and log(distance)*log(distance)

21
Model comparisons

Table 3: Log-likelihood function values for various models

Model log-like
OLS 347.3761
SAR using WJ = Wd only 542.9683
SAR using WJ = Wo only 567.5280
SAR using Wj = Wo + Wd + Wod 604.8205
SAR using WJ = Wo + Wd 617.9472
SAR using (In2 − ρ1Wo − ρ2Wd + ρ1ρ2WoWd) 623.4115
SAR using (In2 − ρ1Wo − ρ2Wd) 624.0966
SAR using (In2 − ρ1Wo − ρ2Wd + ρ3WoWd) 624.6686

Table 4: ρ1, ρ2, ρ3 estimates for various models

Model ρ1 , ρ 2 , ρ 3
OLS 0
WJ = Wd only 0.2759
WJ = Wo only 0.3099
Wj = Wo + Wd + Wod 0.2019
WJ = Wo + Wd 0.2719
(In2 − ρ1Wo − ρ2Wd + ρ1ρ2WoWd) 0.2381, 0.2854
(In2 − ρ1Wo − ρ2Wd) 0.2551, 0.2985
(In2 − ρ1Wo − ρ2Wd + ρ3WoWd) 0.2532, 0.2993, -0.0060

22
23
Variable β t-stat z-prob
constant -1.207 -0.32 0.7425
Darea 0.072 4.09 0.0000
Dpcincome 0.385 2.11 0.0340
Dmales -2.361 -3.28 0.0010
Dfemales 2.935 3.41 0.0006
Dyoung -0.007 -0.04 0.9629
Dnretire -0.380 -1.50 0.1311
Dretired -0.120 -0.62 0.5328
Dborninstate -0.206 -3.71 0.0002
Dforeignborn -0.099 -2.16 0.0303
Dcollege 0.169 1.96 0.0496
Dgradprof -0.009 -0.13 0.8963
Dhousevalue -0.097 -1.66 0.0960
Dtraveltime 0.037 0.29 0.7645
Dunemp 0.076 1.59 0.1116
Dmedianrent -0.287 -1.86 0.0625
Dretireincome -0.389 -4.58 0.0000
Dself-emp -0.217 -4.76 0.0000
Drecentimmigr 0.088 2.28 0.0222
Oarea 0.090 4.95 0.0000
Opcincome 0.185 1.02 0.3071
Omales -0.686 -0.93 0.3473
Ofemales 0.092 0.10 0.9158
Oyoung 0.785 4.64 0.0000
Onretire -1.319 -5.21 0.0000
Oretired 1.079 5.39 0.0000
Oborninstate -0.081 -1.48 0.1374
Oforeignborn 0.132 2.82 0.0047
Ocollege -0.238 -2.70 0.0067
Ogradprof 0.146 2.11 0.0345
Ohousevalue 0.060 1.01 0.3078
Otraveltime 0.514 4.09 0.0000
Ounemp -0.327 -6.39 0.0000
Omedianrent 0.019 0.12 0.8976
Oretireincome -0.198 -2.36 0.0179
Oself-emp -0.100 -2.17 0.0293
Orecentimmigr -0.160 -4.05 0.0000
log(distance) -0.028 -2.08 0.0366
log(distance2) 0.003 2.48 0.0128
rho1 0.253 9.27 0.0000
rho2 0.299 12.93 0.0000
rho3 -0.006 -0.13 0.8896
24
Other issues/Work to be done

• Generalization to contrasts for non-flow spatial data


samples
• Problem: dominant diagonal flows within regions
• Potential solutions: transformations, Bayesian robust
estimates
• Problem: large # of zero flows for fine spatial scales,
e.g., US counties
• Potential solutions: transformations, Bayesian spatial
tobit estimation

25
Conclusions

• It is relatively easy to incorporate spatial lags into


conventional least-squares gravity models
• The log-determinant takes a particularly convenient form,
making it easy to handle models with n2 in the millions

26

You might also like