Announcement

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

  • Spatial Contiguity Weighting Matrix Creation Failed

    Hello, everyone. I am on my spatial research right now for my undergraduate thesis. I have a shp file (_ID, _CX, _CY) that contains an Island with 10 provinces within it, and I have made shp file to dta file. I also merge it with my panel data that consist 10 unit (10 provinces) with the lenght of period from 2014-2023 (10 years). When I need to test the spatial autocorrelation, I create the contiguity matrix first using the command below:


    spmat contiguity Wcon using "Wilayah_Sumatera.dta" if Tahun == 2014, id(_ID) norm(row)

    But the creation is failed and Stata said "variable _X not found" after I ran the command. Is there anyone can help me to solve this problem?

    I really need to use the "spmat" command so I can use "spatdiag, weights(W)" command instead of "estat moran" for the spatial autocorrelation test.

    Thanks.
    Ary Pratama
    Click image for larger version

Name:	Screen Shot 2025-06-10 at 18.12.17.png
Views:	2
Size:	63.4 KB
ID:	1778692
    Attached Files

  • #2
    spmap is from the Stata Journal (FAQ Advice #12). It appears that your coordinates are named differently from _X and _Y in the shape file dataset. Show us the result of

    Code:
    use Wilayah_Sumatera_shp, clear
    dataex in 1/5

    Comment


    • #3
      Thanks, Andrew. I did it, but the _ID obs all become 1 Click image for larger version

Name:	Screen Shot 2025-06-11 at 00.27.55.png
Views:	1
Size:	100.9 KB
ID:	1778707 Click image for larger version

Name:	Screen Shot 2025-06-11 at 00.26.21.png
Views:	1
Size:	119.0 KB
ID:	1778708

      Comment


      • #4
        The coordinates are named _X and _Y, so #2 isn't the problem. Can you share your data?

        Comment

        Working...
        X