[R-sig-Geo] spdep lagsarlm regression error

Martin martin.gubri at framasoft.org
Wed Sep 28 05:23:18 CEST 2016


> It produces the following error.
> Error: length(listw$neighbours) == n is not TRUE


Do you have NA values in your dataframe 'mex'? The problem may be that
using the option 'na.action=na.omit', lagsarlm() subsets the listw
object, then the impact() function is waiting for the listw object of
the subset. So, you may want to try to subset your W object, just before
calling impact().
Also I recommend that you check that your data are in the same order
that your listw object:

> identical(attr(W, 'region.id'), rownames(sar.mex$X))
> identical(attr(W, 'region.id'), names(sar.mex$y))



More information about the R-sig-Geo mailing list