Dear All,
I am constructing some spatial matrices. I have the following coordinates (where _ID identifies the region]:
While I could use spmatrix to create my matrix, the user written spwmatrix routine would allow me to generate a matrix choosing the k nearest neighbours. With the data above, I could write:
However, if I try to use the myW matrix with spregress I get the following error:
I presume that this is due to the fact that spregress does not recognize any spatial object which has not been created using spmatrix.
I tried to generate the above matrix and then to import it using spmatrix import:
The problem is that the matrix myW2 is not normalized (spectral):
Any idea on how to normalize the matrix? Thanks in advance.
I am constructing some spatial matrices. I have the following coordinates (where _ID identifies the region]:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte _ID double(_CX _CY) 1 4.238880806932661 51.0381795797637 2 4.3705583790493465 50.836004194715464 3 5.008810757595679 50.314774734858666 4 9.048183441796569 48.539120289602224 5 7.562275359577741 51.47982042591398 6 9.812804864412303 54.18267278074142 7 9.031162177003864 50.60312939159003 8 9.159366625166365 52.76822315642757 9 11.419101982885781 48.946844237635794 10 -7.910502751973481 42.756695468623235 11 -2.6162526114576328 43.0433556472304 12 -.6599335303805115 41.51954561052405 13 -6.1508402965923334 39.19149210853352 14 -.5548950769729665 39.401518880927945 15 -4.5754816643187635 37.46337461821722 16 -1.4853899956423013 38.00235670507524 17 2.912655060412556 39.57419360329185 18 -15.668155079521242 28.34153154991463 19 -4.782005139037015 41.75429637927728 20 -3.716852162382493 40.4950465162602 21 -3.0047329353222882 39.581044916387285 22 1.5289116704222079 41.798474451952394 23 5.289817422604617 43.58430558367101 24 .8387347371287599 44.338785949212514 25 4.542686675219991 45.517655466556306 26 2.715756068693901 50.4723663905693 27 6.347598245580899 48.17247256770211 28 -1.2573091563937455 47.31613047630117 29 2.5381327644238603 48.292024223497016 30 2.5033493032137306 48.70929509840815 31 9.769067362637838 45.620628170558334 32 8.70486347100189 44.264875054299885 33 14.840443948886977 40.85976362267415 34 6.002563143592553 52.289497160963705 35 4.610661457311046 52.097751734967886 36 6.286832650414219 53.05531323841722 37 5.410618051098782 51.45495894313609 38 12.766735405438116 41.98000397761924 39 16.61930407162165 40.984592383451606 40 11.126082947167264 43.45078957457015 41 11.038069574762444 44.5255464813964 42 16.347610749835038 39.06787919421982 43 -7.678641274716713 41.45752851199433 44 -8.131341102441208 37.24373918509147 45 -9.045001782531612 38.737506880267716 46 -8.014034985515947 38.490875924556505 47 -7.993077306851027 40.133696972864 48 -27.282535206945695 38.34807291397858 49 -16.951549883485765 32.751393510571525 50 -4.184661705559883 56.8395664536139 51 -6.694157393386353 54.60974329011341 52 -3.7637283805348782 52.33639746515705 53 -3.132137327606542 51.00022732220863 54 -.8065406679657919 52.926936493964085 55 -1.229212191489712 53.96554242684258 56 -2.2708002631811794 52.480446124299874 57 7.861511916378289 45.137521996830564 58 11.884422926292736 46.03477268799009 59 12.831751280511003 43.1676278995571 60 14.854738234591938 41.45734716847926 61 11.626845963292368 38.819447705708036 62 -5.337484002822747 43.26057900387312 63 -1.929712993209706 42.5393129401837 64 9.556973106152082 53.42845954603848 65 7.392801608484208 49.85361696167447 66 -2.342632760789819 54.83099522558365 67 -2.5550432219906885 53.548812742891116 68 .955481263001568 52.67083597810112 69 -.14736474261673754 51.61526791744084 end
Code:
spwmatrix gecon _CY _CX, wn(myW) knn(5)
Code:
weighting matrix myW not found
I tried to generate the above matrix and then to import it using spmatrix import:
Code:
spwmatrix gecon _CY _CX, wn(W5) knn(5) xport(myW, txt) replace insheet using "myW.txt", delim(" ") clear spmatrix import myW2 using myW.txt
Code:
. spmatrix summarize my Weighting matrix my --------------------------------------- Type | custom Normalization | none Dimension | 69 x 69 Elements | minimum | 0 minimum > 0 | 1 mean | .0724638 max | 1 ---------------------------------------
Any idea on how to normalize the matrix? Thanks in advance.
Comment