Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Obtaining Moran's I with -moransi-?

    Hi Statalisters

    I am working on spatial autocorrelation using Moran's I with the -moransi- command. I am having some issues with obtaining sensible results and hope that someone may provide input. I have searched for information, but have not found any helpful information on this specific issue. Perhaps other commands for Moran's I may be more suitable.

    I have a data set at municipality level (-munic-) with the variable of interest, -diag_frac-, and variables for longitude and latitude. I have an additional variable -group- with values "1001.x" where x varies for over municipality codes. For example, I have 332 rows for the first municipality and group goes from 1001.1 to 1001.12.

    When I follow the -moransi- syntax, I get the following error message:
    Code:
    . moransi diag_frac, lat(latitude) lon(longitude) swm(pow 3) dist(.) dunit(km)
                         J():  3900  unable to allocate real <tmp>[114695,114695]
               calcmoransi():     -  function returned error
                     <istmt>:     -  function returned error
    r(3900);
    When I use the group variable, I get output (although not very helpful):
    Code:
    . moransi group, lat(latitude) lon(longitude) swm(bin) dist(.) dunit(km)
    Size of spatial weight matrix:        0
    
    Distance by Vincenty formula (unit: km)
    
    Moran's I Statistic                                  Number of Obs =        0
    -----------------------------------------------------------------------------
        Variable |  Moran's I         E(I)        SE(I)         Z(I)      p-value
    -------------+---------------------------------------------------------------
           group |          .      1.00000            .            .            .
    -----------------------------------------------------------------------------
    Null Hypothesis: Spatial Randomization
    Here is an overview of the 10 first observations of 116061 observations:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float munic str7 group float diag_frac double(longitude latitude)
    1001 "1001.1" .0509536 8.185135324837832  58.14294309988497
    1001 "1001.1" .0509536 8.179071228942883  58.13995776977048
    1001 "1001.1" .0509536  8.18477560553609 58.138102104784736
    1001 "1001.1" .0509536 8.178954613870598 58.131509307117305
    1001 "1001.1" .0509536 8.180801932069118  58.12889646551324
    1001 "1001.1" .0509536 8.174042784729531  58.12817274934762
    1001 "1001.1" .0509536 8.169978388722278 58.125305063606575
    1001 "1001.1" .0509536 8.164428225382006  58.12786257501244
    1001 "1001.1" .0509536 8.151078440231464  58.12925255793769
    1001 "1001.1" .0509536  8.15233806989138  58.12608493338922
    end

  • #2
    moransi is from SSC, as your link explains.

    I am not sure what is not clear here. The command wants to create a matrix with about 10 billion cells and that's being refused. So you get no results. There is unlikely to be an easy work-around, but something different may be more interesting or useful any way.

    You say you have data at the municipality level but it seems more likely to me that you have data on individual properties, households or families. If so, there is spatial structure on several different scales.

    Comment


    • #3
      Thanks for your reply! I was working on Stata SE 16.1 yesterday and will give it another shot after transferring the data set to a system where I have access to Stata MP 16.1, and look up other approaches if this does not work out.

      Comment

      Working...
      X