Hello everyone,
I'm working with Stata 13.1 and created a spatial weight matrix using spmat. In the next step, I merged a dataset with the attribute data of the shapefile with another cross-section dataset. However, I get two error messages when I want to conduct a regression. A short version of my do-file:
In case of missing values: Why is spreg not using listwise deletion?
Regarding the second error: Giving that I merged both datasets perfectly and dropped the units that are not in both datasets: Why is Stata not able to match both ids? I tried for hours to solve the problem but I'm really lost here.
I'm working with Stata 13.1 and created a spatial weight matrix using spmat. In the next step, I merged a dataset with the attribute data of the shapefile with another cross-section dataset. However, I get two error messages when I want to conduct a regression. A short version of my do-file:
shp2dta using D:\.....\Shapefile\TM_WORLD_BORDERS-0.3.shp, database(usdb) coordinates(uscoord) genid(id)
use usdb, clear
merge 1:1 WBCode using "D:\...\test.dta"
drop if _merge==1
*** Contiguity Matrix
spmat contiguity W using uscoord , id(id) normalize(minmax)
*** Inverse Distance Matrix
spmat idistance I LON LAT, id(id) dfunction(dhaversine) normalize(minmax)
spmat save W using W.spmat
spmat save I using I.spmat
*** Regression
spreg ml y x, id(id) dlmat(W, eig) elmat(W, eig)
y has missing values
drop if y==.
spreg ml y x, id(id) dlmat(W, eig) elmat(W, eig)
ids in spmat object W do not match ids in variable id
use usdb, clear
merge 1:1 WBCode using "D:\...\test.dta"
drop if _merge==1
*** Contiguity Matrix
spmat contiguity W using uscoord , id(id) normalize(minmax)
*** Inverse Distance Matrix
spmat idistance I LON LAT, id(id) dfunction(dhaversine) normalize(minmax)
spmat save W using W.spmat
spmat save I using I.spmat
*** Regression
spreg ml y x, id(id) dlmat(W, eig) elmat(W, eig)
y has missing values
drop if y==.
spreg ml y x, id(id) dlmat(W, eig) elmat(W, eig)
ids in spmat object W do not match ids in variable id
Regarding the second error: Giving that I merged both datasets perfectly and dropped the units that are not in both datasets: Why is Stata not able to match both ids? I tried for hours to solve the problem but I'm really lost here.