Spatial Lags Excluding Neighbors' Missing Attribute Values
On Tue, 30 Dec 2008, Christopher Moore wrote:
Greetings, I posted a request for assistance on 12/27/08: <https://stat.ethz.ch/pipermail/r-sig-geo/2008-December/004733.html>. I developed a satisfactory solution, which is posted below for others who wish to similarly exclude neighbors' missing attribute values from W style spatial lags.
Well, this is quite a detailed question, and this isn't the best time of
year to get rapid response. I don't think that your solution is
satisfactory - and I don't think that there is any viable alternative to
either imputing to fill all the missing values (I wouldn't do that), or
subsetting out incomplete cases and using the same subset on the "nb"
object (there are subset methods). What happens now is that in the
compiled code in "lagw" the sum is not incremented when the value is not
finite:
sum = 0.0;
for (j=0; j<INTEGER_POINTER(card)[i]; j++) {
k = INTEGER_POINTER(VECTOR_ELT(nb, i))[j];
wt = NUMERIC_POINTER(VECTOR_ELT(weights, i))[j];
tmp = NUMERIC_POINTER(x)[k-ROFFSET];
if (R_FINITE(tmp)) sum += tmp * wt;
}
NUMERIC_POINTER(ans)[i] = sum;
in src/lagw.c. In fact the NAOK argument is not being used, and should be,
so in the next release you will either get an error, or, for NAOK=TRUE,
you'll get an NA for the lagged value - that was the intention. If you can
make a case for a third choice, essentially doing what you describe, I can
consider it, but being conservative, missing data is missing, really,
isn't it?
Best wishes,
Roger
I did not receive any responses to my original message but would still appreciate any thoughts or suggestions regarding this approach or the general problem of neighbors with missing attribute values. For example, do spatial statisticians prefer to impute missing attribute values before lagging, or is there a good justification for treating NA as zero when calculating spatial lags, thereby pulling lagged values downward? Thanks, Chris
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no