Announcement

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

  • How to create spatial weight matrix using shapefile in a Panel Data set?

    Hello,
    I have a panel dataset and I want to perform some of the spatial panel analysis.
    Now I am trying to generate spatial weight using shapefile with spset and spmatrix commands from drop down menu. I have linked stata format shapefile data also.
    But whenever I want to create the weight matrix, this message comes - "variable _ID does not uniquely identify observations in the master data".
    The variable _ID must be repetitive as it is a panel data.

    How to solve this issue?

    And further, how can I create spatial weight matrix (band based or contiguity) in a panel data?


  • #2
    You must restrict the dataset to a cross-section that includes all units to create the matrix. This is discussed in the documentation of spmatrix. See #5 of this thread for an illustration: https://www.statalist.org/forums/for...ate-contiguity

    Comment


    • #3
      BUt I have a panel dataset and I want to use spatial techniques in panel data only. Then how to generate the spatial weight for panel data, could you please let me know?

      Comment


      • #4
        I referred you to the link in #2. The restriction concerns only creation of the matrix. You xtset the data, create the matrix using the -if- qualifier and finally spset. From the result shown in the linked thread, spset does indeed acknowledge the panel structure of the data.

        . spmatrix create contiguity W if year==2000
        weighting matrix in W contains 7 islands

        . spset
        Sp dataset shp_59_country2_1134_sodan.dta
        data: panel
        spatial-unit id: _ID (equal to country)
        time id: year (see xtset)
        coordinates: _CY, _CX (latitude-and-longitude, miles)
        linked shapefile: afr_g2014_2013_0_shp.dta
        Take your time to review and understand the example in the linked thread.

        Comment


        • #5
          Thanks I understood that. Now I want to use the command spregxt which needs weight matrix file as separate dta file. Can you tell me how to generate and save particular weight matrix dta file in this case?

          Comment


          • #6
            https://www.statalist.org/forums/for...-weight-matrix


            Please start a new thread if you have more questions unrelated to the topic of this thread.

            Comment


            • #7
              actually I am using 'spregdpd' command to run a spatial dynamic panel data model. I have created a cross section spatial weights matrix using the command 'spmatrix' with number of cross sections are 361 districts in my case.But when I opened the weights file in stata it has 361 rows but in one column I have all the 361 values as weights. So the command is not working


              Comment

              Working...
              X