<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Dear all,<br>
<br>
I seem to have a serious problem with create_WX().<br>
<br>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln">library</span><span class="pun">(</span><span class="pln">spdep</span><span class="pun">)</span><span class="pln">
data</span><span class="pun">(</span><span class="pln">oldcol</span><span class="pun">)</span><span class="pln"></span><span class="pln">
lw </span><span class="pun"><-</span><span class="pln"> nb2listw</span><span class="pun">(</span><span class="pln">COL</span><span class="pun">.</span><span class="pln">nb</span><span class="pun">,</span><span class="pln"> style</span><span class="pun">=</span><span class="str">"W"</span><span class="pun">)</span><span class="pln"></span><span class="pln">
X </span><span class="pun"><-</span><span class="pln"> COL</span><span class="pun">.</span><span class="pln">OLD</span><span class="pun">[,</span><span class="pln"> c</span><span class="pun">(</span><span class="str">"INC"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"HOVAL"</span><span class="pun">)]</span><span class="pln"></span><span class="pln">
WX </span><span class="pun"><-</span><span class="pln"> create_WX</span><span class="pun">(</span><span class="pln">X</span><span class="pun">,</span><span class="pln"> lw</span><span class="pun">)</span><span class="pln"></span><span class="pun"></span></code></pre>
creates a matrix with the last row being NA only. Why is that?
However, building X using<br>
<br>
<pre wrap="">X <- model.matrix(CRIME ~ INC + HOVAL, data=COL.OLD)
<code><span class="pln">WX </span><span class="pun"><-</span><span class="pln"> create_WX</span><span class="pun">(</span><span class="pln">X</span><span class="pun">,</span><span class="pln"> lw</span><span class="pun">)</span></code>
</pre>
everything works, but both X look exactly similar to each other
(except for the attribute and the "(Intercept)" column.<br>
<br>
Kind regards,<br>
Michael <br>
<br>
</body>
</html>