Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: spatial analysis - DISTANCE


From   Scott Merryman <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: spatial analysis - DISTANCE
Date   Sun, 30 Aug 2009 11:07:11 -0500

Sorry - I forgot to mention the code uses Ben Jann's -moremata-.

What is the error?

The example returns the distance matrix and neighbor matrix and then
creates the N variables in the original data set:

: dist
[symmetric]
                 1             2             3             4
  5             6             7             8             9
    +-------------------------------------------------------------------------------------------------------------------------------+
  1 |            0
                                                             |
  2 |  5.157033248             0
                                                             |
  3 |  21.21062478   21.71534226             0
                                                             |
  4 |  26.95060264   27.64838102   5.939930861             0
                                                             |
  5 |   16.1570544    21.1565295   30.29833499    34.5960745
  0                                                          |
  6 |  14.73674249   19.76346139   22.78331973   26.58113711
8.439103366             0                                            |
  7 |  6.614080612   9.633040063    15.1934957   20.70923619
17.14313644   12.30209368             0                              |
  8 |    22.069818   20.34155009   9.309128607   12.92307095
35.0470512   28.79024435   18.03555849             0                |
  9 |  20.67616548   20.42184227   3.226163273   8.078752624
31.37740006   24.32651125   15.24958295   6.116268222             0  |
    +-------------------------------------------------------------------------------------------------------------------------------+



     +-----------------------------------------------------------------------+
     | id   latitude   longit~e   N1   N2   N3   N4   N5   N6   N7   N8   N9 |
     |-----------------------------------------------------------------------|
  1. |  1     .23851   .0647102    1    1    0    0    0    0    1    0    0 |
  2. |  2   .1653217   .0502572    1    1    0    0    0    0    1    0    0 |
  3. |  3   .1722953   .3643155    0    0    1    1    0    0    0    1    1 |
  4. |  4   .1788673   .4499913    0    0    1    1    0    0    0    0    1 |
  5. |  5   .4713051    .043847    0    0    0    0    1    1    0    0    0 |
     |-----------------------------------------------------------------------|
  6. |  6   .4298635   .1586816    0    0    0    0    1    1    0    0    0 |
  7. |  7    .251903   .1594484    1    1    0    0    0    0    1    0    0 |
  8. |  8   .0454795   .3190092    0    0    1    0    0    0    0    1    1 |
  9. |  9   .1304665   .3436173    0    0    1    1    0    0    0    1    1 |
     +-----------------------------------------------------------------------+



Why do you want to store the neighboring unit ids?

Scott

On Sun, Aug 30, 2009 at 10:40 AM, David Torres<torresd@umich.edu> wrote:
> I copied and pasted your example, Scott, and got a couple of error messages
> about N matrix not found.  I installed the moremata files, but this didn't
> solve the problem.  I'm not quite as adept at using stata as some, so,
> please, bear with me.  I've never used a mata command, so would like to know
> whether its use will allow for variable creation wheere the unitids can be
> stored and reshaped and all that jazz?
>
> Thanks,
> --------------------------------------------
>
> David Diego Torres, MA(Sociology)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index