[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-geo
Subject: Re: [R-sig-Geo] Spatial Lags Excluding Neighbors' Missing Attribute
From: Roger Bivand <Roger.Bivand () nhh ! no>
Date: 2008-12-31 11:36:57
Message-ID: alpine.LRH.2.00.0812311223420.5052 () reclus ! nhh ! no
[Download RAW message or body]
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@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic