Announcement

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

  • Stata Map

    Hi All,
    I have plotted my data on a map in stata for different time periods. But in one of my maps, some parts of the map is not showing and instead of four legends only 3 is showing. I tried inspecting the data and see if there are missing values but found none. I cannot figure out why portion of the map is not showing. Any help will be appreciated.
    The data I used is as below;


    . dataex STATE NAME FIPS LON LAT id code frrid State y1 y2 y3 y4

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str2 STATE str20 NAME str2 FIPS float(LON LAT) byte id float(code frrid) str2 State double(y1 y2 y3 y4)
    "AL" "Alabama"        "01"  -86.82676 32.79354  2  1 9 "AL"  .0926 .1218 .1573 .1546
    "AR" "Arkansas"       "05"   -92.4392 34.89977  3  2 8 "AR"  .0365 .0957 .1488 .1598
    "AZ" "Arizona"        "04" -111.66457 34.29323  5  3 2 "AZ"  .0991 .1156 .1355 .1491
    "CA" "California"     "06" -119.60818 37.24537  6  4 2 "CA"  .0991 .1156 .1355 .1491
    "CO" "Colorado"       "08" -105.54783 38.99855  7  5 1 "CO"  .2012 .1307 .1474  .177
    "CT" "Connecticut"    "09"  -72.72623 41.62196  8  6 7 "CT"  .1307 .1373 .1549 .1771
    "DE" "Delaware"       "10"  -75.50592 38.99559 10  7 9 "DE"  .0926 .1218 .1573 .1546
    "FL" "Florida"        "12"  -82.50934 28.67402 11  8 2 "FL"  .0991 .1156 .1355 .1491
    "GA" "Georgia"        "13"  -83.44848 32.65155 12  9 9 "GA"  .0926 .1218 .1573 .1546
    "IA" "Iowa"           "19"  -93.50003 42.07463 14 10 5 "IA"  .1467 .1544 .1601 .1588
    "ID" "Idaho"          "16" -114.65933 44.38907 15 11 2 "ID"  .0991 .1156 .1355 .1491
    "IL" "Illinois"       "17"  -89.19838 40.06501 16 12 5 "IL"  .1467 .1544 .1601 .1588
    "IN" "Indiana"        "18"  -86.27548 39.90801 17 13 5 "IN"  .1467 .1544 .1601 .1588
    "KS" "Kansas"         "20"  -98.38019 38.48471 18 14 4 "KS"  .1403 .1615  .203 .2052
    "KY" "Kentucky"       "21"  -85.29046 37.52668 19 15 8 "KY"  .0365 .0957 .1488 .1598
    "LA" "Louisiana"      "22"  -92.02905  31.0891 20 16 6 "LA" -.0537 .0738 .1467 .1628
    "MA" "Massachusetts"  "25"  -71.81423 42.25788 21 17 7 "MA"  .1307 .1373 .1549 .1771
    "MD" "Maryland"       "24"  -76.78588 39.04533 56 18 9 "MD"  .0926 .1218 .1573 .1546
    "ME" "Maine"          "23"  -69.22999 45.38046 22 19 7 "ME"  .1307 .1373 .1549 .1771
    "MI" "Michigan"       "26"  -85.43675 44.34717 23 20 7 "MI"  .1307 .1373 .1549 .1771
    "MN" "Minnesota"      "27"  -94.31357 46.31189 24 21 7 "MN"  .1307 .1373 .1549 .1771
    "MO" "Missouri"       "29"  -92.38554  38.3208 52 22 5 "MO"  .1467 .1544 .1601 .1588
    "MS" "Mississippi"    "28"  -89.66553 32.75201 25 23 6 "MS" -.0537 .0738 .1467 .1628
    "MT" "Montana"        "30" -109.64507  47.0335 26 24 1 "MT"  .2012 .1307 .1474  .177
    "NC" "North Carolina" "37"  -79.37865 35.54369 27 25 9 "NC"  .0926 .1218 .1573 .1546
    "ND" "North Dakota"   "38" -100.46935 47.44626 28 26 3 "ND"   .168 .1664 .1829 .2262
    "NE" "Nebraska"       "31"  -99.81058 41.52709 29 27 3 "NE"   .168 .1664 .1829 .2262
    "NH" "New Hampshire"  "33"  -71.57754 43.68556 30 28 7 "NH"  .1307 .1373 .1549 .1771
    "NJ" "New Jersey"     "34"  -74.66876 40.20049 31 29 7 "NJ"  .1307 .1373 .1549 .1771
    "NM" "New Mexico"     "35" -106.10837 34.42137 32 30 1 "NM"  .2012 .1307 .1474  .177
    "NV" "Nevada"         "32" -116.65539 39.35648 33 31 1 "NV"  .2012 .1307 .1474  .177
    "NY" "New York"       "36"  -75.51491 42.94796 34 32 7 "NY"  .1307 .1373 .1549 .1771
    "OH" "Ohio"           "39"  -82.79002  40.2912 35 33 5 "OH"  .1467 .1544 .1601 .1588
    "OK" "Oklahoma"       "40"  -97.50819 35.58345 36 34 4 "OK"  .1403 .1615  .203 .2052
    "OR" "Oregon"         "41" -120.55232 43.93589 37 35 1 "OR"  .2012 .1307 .1474  .177
    "PA" "Pennsylvania"   "42"   -77.7993 40.87368 38 36 7 "PA"  .1307 .1373 .1549 .1771
    "RI" "Rhode Island"   "44"  -71.55579 41.67544 40 37 7 "RI"  .1307 .1373 .1549 .1771
    "SC" "South Carolina" "45"  -80.89899 33.93574 53 38 9 "SC"  .0926 .1218 .1573 .1546
    "SD" "South Dakota"   "46" -100.23048 44.43614 41 39 3 "SD"   .168 .1664 .1829 .2262
    "TN" "Tennessee"      "47"  -86.34332 35.84299 42 40 8 "TN"  .0365 .0957 .1488 .1598
    "TX" "Texas"          "48"  -99.35939 31.49422 43 41 4 "TX"  .1403 .1615  .203 .2052
    "UT" "Utah"           "49" -111.67822 39.32379 44 42 1 "UT"  .2012 .1307 .1474  .177
    "VA" "Virginia"       "51"  -78.82957 37.51637 45 43 9 "VA"  .0926 .1218 .1573 .1546
    "VT" "Vermont"        "50"  -72.66273 44.07511 47 44 7 "VT"  .1307 .1373 .1549 .1771
    "WA" "Washington"     "53" -120.43997 47.38076 48 45 2 "WA"  .0991 .1156 .1355 .1491
    "WI" "Wisconsin"      "55"  -90.01144 44.63725 49 46 7 "WI"  .1307 .1373 .1549 .1771
    "WV" "West Virginia"  "54"  -80.61372 38.64259 50 47 8 "WV"  .0365 .0957 .1488 .1598
    "WY" "Wyoming"        "56" -107.55144 42.99963 51 48 1 "WY"  .2012 .1307 .1474  .177
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 48 out of 48 observations

    With the command
    foreach var in y1 y2 y3 y4 y5 y6 y7 y8 y9 y10{
    spmap `var' using uscoord if frrid !=., id(id) fcolor(Greens) name(`var',replace)
    }


    Thanks,
    Francis

  • #2
    Probably you should specify the number of classes (less than 4)
    spmap `var' using coor, id(id) fcolor(Greens) name(`var',replace) cln(3)
    or specifying the method : clmethod(unique)

    Comment


    • #3
      Dear Francis,

      thank you for posting the data example.

      I have replicated the issue using spmap (which may or may not be the most recent version)
      . which spmap
      c:\ado\plus\s\spmap.ado
      *! -spmap-: Visualization of spatial data
      *! Version 1.2.0 - 14 March 2008
      *! Author: Maurizio Pisati
      Please read the FAQ, especially #12.1 https://www.statalist.org/forums/help

      I have further used the data you provided with amap and it created the legend with 4 ranges. (Clustering parameters: percentiles, 4 intervals). Perhaps this can be used to determine where the problem is, as the first interval boundaries look identical between the two programs.

      Best, Sergiy Radyakin

      Click image for larger version

Name:	amap_legend.png
Views:	1
Size:	11.9 KB
ID:	1422611

      Legend in spmap:
      Click image for larger version

Name:	spmap_legend.png
Views:	1
Size:	1.7 KB
ID:	1422612

      Comment


      • #4
        Alexander Baldeon ,

        I think Francis is asking why given the default setting (implying clnumber(4) ) he is getting only 3 intervals in the legend, and only sometimes (for some variables).
        One can, of course, create alternative visualizations. The question is why this specific one didn't work as intended?

        Best, Sergiy

        Comment


        • #5
          Sergiy Radyakin ,
          Exactly my point'. I don't understand why the default is not returning four legends and some parts of the map also getting missing. And please I tried reading on amap but cannot find any information with 'help amap' command in stata. I would be glad to know more about amap

          Francis

          Comment

          Working...
          X