Dear All,
I am trying to estimate a spatial lag model with the spdep package in R. I
have been reading previous posts and I have managed to resolve most of the
issues I was running into except when I try estimating the impacts of the
spatial lag model using impacts. It produces the following error.
Error: length(listw$neighbours) == n is not TRUE
I enclose the code I have followed:
ID_ <- unique(ba0$V1)
ba <- read.gwt2nb("/Volumes/Transcend/Municipios/Municipiosa.gwt",
region.id=ID_)
Warning message:
In read.gwt2nb("/Volumes/Transcend/Municipios/Municipiosa.gwt", :
356, 642, 2286, 2334, 2448 are not destinations
ba
Neighbour list object:
Number of regions: 2456
Number of nonzero links: 12280
Percentage nonzero weights: 0.2035831
Average number of links: 5
Non-symmetric neighbours list
Error: unexpected symbol in "impacts(sar.mex listw"
impacts(sar.mex, listw=W)
*Error: length(listw$neighbours) == n is not TRUE*
I know I am doing something wrong and I have not managed to fix that last
error. Any advice will be greatly appreciated
Thanks
Erik Alda
Doctoral Candidate
Department of Justice, Law and Criminology
School of Public Affairs
The American University, Washington, D.C.
Alt.e-mail: ea3466a at american.edu
[[alternative HTML version deleted]]
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: