Hello everone,
I am doing a spatial panel data analysis. Suppose that I have created (using other command) a spatial weight matrix and now stored in my working directory as W_xyz.txt. the matrix is however in cross section version ie a matrix of 85x85 since my panel data has N=85 (and T=6).
Then I run the following command in STATA:
However STATA gives me the following error which I understand the reason because my matrix is in CS version (85x85) but the regress command is done on a panel data.
Please help me how to convert the matrix into panel version ie. 85*6x85*6.
Thanks so much.
I am doing a spatial panel data analysis. Suppose that I have created (using other command) a spatial weight matrix and now stored in my working directory as W_xyz.txt. the matrix is however in cross section version ie a matrix of 85x85 since my panel data has N=85 (and T=6).
Then I run the following command in STATA:
*load the dataset
use growthdata.dta, clear
assert countryid!=.
assert year!=.
bysort countryid year: assert _N==1
xtset, clear
xtset countryid year
spbalance
spset countryid
*now import the W_xyz.txt using spmatrix import
spmatrix import W_xyz using W_xyz.txt
spmatrix normalize W_xyz
*now test for Moran's I
reg y x1 x2 x3
estat moran, errorlag(W_xyz)
use growthdata.dta, clear
assert countryid!=.
assert year!=.
bysort countryid year: assert _N==1
xtset, clear
xtset countryid year
spbalance
spset countryid
*now import the W_xyz.txt using spmatrix import
spmatrix import W_xyz using W_xyz.txt
spmatrix normalize W_xyz
*now test for Moran's I
reg y x1 x2 x3
estat moran, errorlag(W_xyz)
_IDs in weighting matrix W_xyz do not match _IDs in estimation sample
There are places in W_xyz not in estimation sample and places in estimation sample not in W_xyz.
There are places in W_xyz not in estimation sample and places in estimation sample not in W_xyz.
Please help me how to convert the matrix into panel version ie. 85*6x85*6.
Thanks so much.