Hi,
I have an question on how to modify the spatial weight matrix created by spmat. First,many thanks for so perfect commands written by David Drukker et tal.,
I have download the shape file for china province from http://www.gadm.org/country. The command used are as following
From the above results we can see that
In fact, Hainan province in China is island from geographical position. I assume that Hainan (id = 9) and Guangdong (id=6) province
has a common boundary, so I should modify the spatial weight matrix.Following the http://econweb.umd.edu/~prucha/paper...PMAT(2013).pdf,
the codes used as following
However, the above codes are not working well. Many thanks for any suggestions.
Best regards,
wanhaiyou
I have an question on how to modify the spatial weight matrix created by spmat. First,many thanks for so perfect commands written by David Drukker et tal.,
I have download the shape file for china province from http://www.gadm.org/country. The command used are as following
Code:
clear shp2dta using CHN_adm1, database(china) coordinates(chinaxy) genid(id) gencentroids(c) replace use china,clear spmap using chinaxy, id(id) drop if NAME_1 == "Xizang" spmap using chinaxy, id(id) rename x_c longitude rename y_c latitude save china, replace *** creat rook contiguity weight matrix spmat contiguity c_china using chinaxy, id(id) rook replace spmat save c_china using ccounty.spmat spmat drop ccounty spmat use ccounty1 using ccounty.spmat **export weight matrix to txt file spmat export ccounty1 using weight.txt,replace spmat summarize ccounty1, links
Code:
warning: spatial-weighting matrix contains 1 island
has a common boundary, so I should modify the spatial weight matrix.Following the http://econweb.umd.edu/~prucha/paper...PMAT(2013).pdf,
the codes used as following
Code:
spmat import weight_revise using weight.txt, replace spmat getmatrix weight_revise w mata:w[6,9]=1 mata:w[9,6]=1 spmat putmatrix weight_revise1 w, normalize(row) replace spmat summarize weight_revise1, links
Best regards,
wanhaiyou
Comment