I tried to create an inverse spatial weight matrix, but without success. I rely on a cross-sectional firm-level dataset which consists of more than 90,000 observations. For each firm I have information about the Latitude and the Longitude.
My data look like this:
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input float ID double(Revenues Ebitda Longitude Latitude)
2 38624.446 3741.754 45.485734 11.418047
3 16322.134 1397.343 45.578752 12.373638
4 3806.701 187.363 44.913215 8.616946
5 923.103 26.39 45.465844 12.217479
7 1629.393 148.883 45.621295 8.865697
8 936.349 62.485 45.615311 8.836641
9 821.583 40.058 44.17739 12.292067
10 2172.014 172.566 45.605449 8.870614
11 3553.138 416.369 37.180847 15.128322
12 6428.817 1110.01 44.510647 11.833396
end
[/CODE
First, I set spatial data by typing:
Code:
spset ID, coord(Longitude Latitude) coordsys(latlong, kilometers)
Code:
spmatrix create idistance idW, normalize(none)
Code:
Two or more observations have the same coordinates r(498);
Code:
set seed 10000 gen double shuffle1 = runiform(0.00000000001,0.00000000002) replace _CX =_CX +shuffle1 if tag>0 replace _CY =_CY +shuffle1 if tag>0
Code:
duplicates report _CX _CY
Code:
-------------------------------------- copies | observations surplus ----------+--------------------------- 1 | 92000 0 --------------------------------------
Code:
spmatrix create idistance idW, normalize(none)
Code:
Division by zero: Two or more observations have the same coordinates r(498);
Thank you in advance for your support.
Best,
Stefano
0 Response to spmatrix -same coordinates
Post a Comment