[R-sig-Geo] self-made WX in lagsarlm

Roger Bivand Roger.Bivand at nhh.no
Mon May 18 10:19:32 CEST 2015


On Sun, 17 May 2015, Michael E. Rose wrote:

> 
> Dear colleagues,
> 
> I would like to estimate a spatial Durbin model with two different weight
> matrices (the second one being standardized, the first one not).
> 
> Hence, I used lagsarlm(..., type="mixed", ...) and wanted to create WX
> myself using create_WX():
> 
> WX <- create_WX(X, average.listw, prefix = "lag")
> 
> X is the matrix of regressors and average.listw is a listw object created
> with mat2listw(..., style="M").

Be careful with using matrices created elsewhere, as you may not have the 
insight you believe into the structures involved (row/column order is not 
infrequently changed). style="M" is equivalent to unknown, and should be 
known.

> 
> Now my problem is: How can I add WX to the regression formula? Simply adding
> the names of WX doesn't work, since WX is not a data.frame which can be
> added to the dataset specified in lagsarlm(..., data= ...).
>

This isn't the real problem. This will actually be the fact that the 
impacts (see references to ?spdep::impacts) are unknown, as the reduced 
form - data generation process of what you want to do is:

y = (I - rho_{Lag} W)^{-1} (Xb + WXg + W*Xd + e)

where W is the weights object in the lag model applied to the dependent 
variable, g are the spatial Durbin coefficients. W* is your extra weights 
object, for which none of b, g, or d may be inferred from directly as 
the impacts of changes in X on y are filtered through (I - rho_{Lag} 
W)^{-1}.

y = (I - rho_{Lag} W)^{-1} (Xb + W*Xd + e)

is a lag model, and

y = (I - rho_{Lag} W)^{-1} ([X, WX][b,g] + W*[X, WX][c,d] + e)

is an augmented spatial Durbin, for both of which something is known about 
impacts.

Adding a matrix to a formula is trivial by comparison:

library(spdep)
data(oldcol)
lw <- nb2listw(COL.nb, style="W")
X <- model.matrix(CRIME ~ INC + HOVAL, data=COL.OLD)
class(X)
WX <- create_WX(X, lw)
class(WX)
lm(CRIME ~ INC + HOVAL + WX, data=COL.OLD)

and equivalently elsewhere, but until you resolve the impacts, do not use 
models including a coefficient on the spatially lagged dependent variable.

Roger

> Any help is greatly appreciated!
> Michael
> 
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list