Skip to content
Prev 4740 / 29559 Next

Spatial Lags Excluding Neighbors' Missing Attribute Values

On Tue, 30 Dec 2008, Christopher Moore wrote:

            
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