Announcement

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

  • Moran's I in Stata

    Dear all,

    I have two questions:

    1) I generated a spatial weights Matrix using spmat. I need to calculate the Moran's I. Do you have any hint on how to do that?

    2) Is it possible to generate a .dta file containing the spatial weights I generated with spmat?

    Thanks in advance

    Dario

  • #2
    Hello "dmaimone",

    I'm not acquainted with the SJ spmat. That said, according to the article published in The Stata Journal (Creating and managing spatial-weighting
    matrices with the spmat command, 2013, 13, Number 2, pp. 242–286), you can save the object by typing:

    Code:
    . spmat save objname using filename [, replace]
    Also,

    spmat dta imports a spatial-weighting matrix from the variables in a Stata dataset and
    stores it in an spmat object.

    Finally, the option

    saving(filename[ , replace]) saves the neighbor list to a space-delimited text file. The first line of the file contains the number of units and, if applicable, bands; each remaining line lists a unit identification code followed by the identification codes of units that share a common border, if any. You can read the file back into an spmat object with spmat import ..., nlist. replace allows filename to be overwritten if it already exists
    Hopefully that helps.
    Best regards,

    Marcos

    Comment


    • #3
      Hi Marcos. Thanks for your reply. Apparently it is not possible to Save the matrix in dta format, which is required to use spatgsa routine. However o found a solution at this link: http://www.stata.com/statalist/archi.../msg00792.html

      Best

      Dario

      Comment


      • #4
        Thanks for sharing the CODE, Dario. By the way, as you may well know, Maurizio Pisati has authored several user-written programs related to spatial analysis in Stata.
        Best regards,

        Marcos

        Comment


        • #5
          Indeed. They are incredibly useful!

          Best

          Da​​rio

          Comment

          Working...
          X