I am trying to create spatial lag variable manually using spgenerate command. I first create my spatial weight matrix and the use that to multiply the variable I want to spatially lag. Below is my code:
Code:
**xtset the data.
xtset ID YEAR
save mypanel, replace
**Spset data
use mypanel
spset ID, coord(lon lat)
**Set the coordinate units, if necessary
spset, modify coordsys(latlong)
spset, modify coordsys(latlong, miles)
**Save the data
save, replace
***Create inverse distance weight matrix W for point locations within 0.5miles radius
spmatrix create idistance W if YEAR == 2009, vtruncate(2) normalize(row)
spmatrix summarize W
Weighting matrix W
---------------------------------------
Type | idistance
Normalization | row
Dimension | 2105 x 2105
Elements |
minimum | 0
minimum > 0 | .0572685
mean | .0003566
max | 1
---------------------------------------Code:
spgenerate Wfee = W*fee
Code:
_IDs in weighting matrix W do not match _IDs in estimation sample
There are places in W not in estimation sample and places in estimation sample not in W05.Any help is much appreciated.
Thank you.
0 Response to Error using spgenerate
Post a Comment