<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;" lang="x-western">
<pre wrap="">
On 18/05/15 10:19, Roger Bivand wrote:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">On Sun, 17 May 2015, Michael E. Rose wrote:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">X is the matrix of regressors and average.listw is a listw object
created
with mat2listw(..., style="M").
</pre>
</blockquote>
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">I used M because it was the first option that delivered my what I needed
(a non-weighted binary matrix). But you are right, B would have been better.
</pre>
<blockquote type="cite" style="color: #000000;">
<blockquote type="cite" style="color: #000000;">
<pre wrap="">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= ...).
</pre>
</blockquote>
<pre wrap="">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)
</pre>
</blockquote>
<pre wrap="">No, I am interested in
y = (I - rho_{Lag} W)^{-1} (Xb + W*Xd + e)
sorry if I wasn't clear about that.
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">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)
</pre>
</blockquote>
<pre wrap="">One thing I don't understand. Shouldn't the last command give the same
results as
lagsarlm(CRIME ~ INC + HOVAL, listw=lw, data=COL.OLD, type="mixed")
Michael
</pre>
</div>
</body>
</html>