Announcement

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

  • Labelling the

    Dear members of the list,

    I am using time-series cross-section (TSCS) analysis to analyse regional differences in a number of labour market outcomes in Spain. My time variable ('ciclo') captures the term of the year and the regional variable ('ccaa') has 17 categories, corresponding to the seventeen Spanish Autonomous Communities.

    I am trying to draw a graph showing the behaviour of one of my independent variables (temporary employment rate, 'z_tem_emp_rate') across the different regions (Autonomous Communities) considered

    First, I set the dataset as time series data

    HTML Code:
    tsset ccaa ciclo, quarterly
    Since I want to plots corresponding to the different regions appear in the same graph, I use overlay in the following order

    Code:
    xtline z_tem_emp_rate if ciclo>60, overlay leg(all on)
    The results is as follows....

    Click image for larger version

Name:	For Statalist.png
Views:	1
Size:	227.9 KB
ID:	1507134


    I would like each plot to be accompanied by the name (label) of the region in the inner part of the graph. I have thoroughly explored the options available of the 'xtline' command, but to no avail. I would deeply appreciate if you could offer me some guideline in this respect.

    Just in case, I insert next a sample of my data

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(ciclo ccaa z_tem_emp_rate) byte _freq
    59  1  -1.0154017 1
    59  2   -1.791009 1
    59  3   -2.543239 1
    59  4   -2.224833 1
    59  5  -.59194607 1
    59  6  -2.3164072 1
    59  7  -1.9033085 1
    59  8  -1.9221123 1
    59  9   -1.709522 1
    59 10  -1.1574327 1
    59 11     -.25603 1
    59 12   -2.582195 1
    59 13  -3.3089216 1
    59 14   -.2878989 1
    59 15  -2.3756084 1
    59 16   -2.604527 1
    59 17   -.5279933 1
    60  1   -.5582552 1
    60  2   -1.647378 1
    60  3  -2.0328357 1
    60  4  -1.7973913 1
    60  5  -.09584047 1
    60  6  -2.3822641 1
    60  7  -1.3078933 1
    60  8   -.8574826 1
    60  9  -1.1714953 1
    60 10   -.7431656 1
    60 11   -.7386317 1
    60 12  -2.3983326 1
    60 13   -3.095677 1
    60 14   .20815425 1
    60 15  -1.0832539 1
    60 16  -1.9598125 1
    60 17   -.6674293 1
    61  1  -.28132015 1
    61  2  -1.4726932 1
    61  3  -2.0550795 1
    61  4  -1.9746982 1
    61  5   -.4151824 1
    61  6  -2.1583295 1
    61  7   -1.082675 1
    61  8   -.7250075 1
    61  9  -1.0431526 1
    61 10   -.3485811 1
    61 11  -.14234784 1
    61 12  -2.3683813 1
    61 13  -3.1720665 1
    61 14    .3212735 1
    61 15  -1.5368887 1
    61 16  -1.8481438 1
    61 17   -.7057295 1
    62  1    .3815298 1
    62  2  -1.4582257 1
    62  3  -1.9586397 1
    62  4  -2.0304658 1
    62  5   .21002254 1
    62  6   -2.374706 1
    62  7   -1.073216 1
    62  8   -.5524626 1
    62  9  -1.0950619 1
    62 10  -.23477216 1
    62 11   -.6348465 1
    62 12   -2.155959 1
    62 13   -3.088883 1
    62 14   .24435814 1
    62 15    -1.57846 1
    62 16  -1.7123057 1
    62 17  -1.1415132 1
    63  1   .43686765 1
    63  2  -1.1760312 1
    63  3   -1.588952 1
    63  4  -1.6115744 1
    63  5  .027266195 1
    63  6  -2.3483164 1
    63  7   -.8027164 1
    63  8  -.23099083 1
    63  9   -.9581966 1
    63 10  -.25828326 1
    63 11  -.20016885 1
    63 12  -1.7336764 1
    63 13   -2.952261 1
    63 14     .605766 1
    63 15    -.551167 1
    63 16  -1.4057535 1
    63 17    -.651881 1
    63 18           . 1
    64  1    .1976862 1
    64  2   -.7347275 1
    64  3   -1.099525 1
    64  4  -1.2297797 1
    64  5   .17768997 1
    64  6  -1.7937908 1
    64  7    -.366861 1
    64  8   .58688307 1
    64  9  -.42775765 1
    64 10 -.005244327 1
    64 11    .9267005 1
    64 12  -1.2843065 1
    64 13   -2.634599 1
    64 14    .9048679 1
    end
    format %tq ciclo
    label values ciclo ciclolll
    label def ciclolll 59 "T2-1987", modify
    label def ciclolll 60 "T3-1987", modify
    label def ciclolll 61 "T4-1987", modify
    label def ciclolll 62 "T1-1988", modify
    label def ciclolll 63 "T2-1988", modify
    label def ciclolll 64 "T3-1988", modify
    label values ccaa ccaal
    label def ccaal 1 "Andaluc�a", modify
    label def ccaal 2 "Arag�n", modify
    label def ccaal 3 "Asturias", modify
    label def ccaal 4 "Baleares", modify
    label def ccaal 5 "Canarias", modify
    label def ccaal 6 "Cantabria", modify
    label def ccaal 7 "Castilla-Le�n", modify
    label def ccaal 8 "Castilla-La Mancha", modify
    label def ccaal 9 "Catalu�a", modify
    label def ccaal 10 "Comunidad Valenciana", modify
    label def ccaal 11 "Extremadura", modify
    label def ccaal 12 "Galicia", modify
    label def ccaal 13 "Madrid", modify
    label def ccaal 14 "Murcia", modify
    label def ccaal 15 "Navarra", modify
    label def ccaal 16 "Pa�s Vasco", modify
    label def ccaal 17 "Rioja", modify
    label def ccaal 18 "Ceuta y Melilla", modify
    At any rate, thanks for your attention

    Best

    Luis Ortiz

    PD: I am aware that a graph with 17 lines is unbearable. I just want to know how to proceed to introduce the labels in the inner part of the graph before proceeding to select units (regions) for different graphs

  • #2
    Here is a technique - only recommended if the number of lines is not too many. Otherwise, there are better looking graphs out there.

    Code:
    bys ccaa (ciclo): gen lastob=_n== _N
    decode ccaa, gen(sccaa)
    tsset ccaa ciclo, quarterly
    xtline z_tem_emp_rate if ciclo>60 & inlist(ccaa,6,10), overlay leg(off) \\\
    addplot(scatter z_tem_emp_rate ciclo if ciclo>60 & inlist(ccaa,6,10) & \\\ 
    lastob, mcolor(none) mlab(sccaa)) scheme(s1color)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	99.9 KB
ID:	1507159

    Comment


    • #3
      I think you might find this thread useful as a starting point. Someone might have other suggestions or ways to go about this, but for what it's worth I would suggest considering fabplot (from SSC).

      Code:
      fabplot connected z_tem_emp_rate ciclo  if ciclo>60 , by(ccaa , rows(3) compact) xlab(, angle(v)) xtitle("")  ytitle("Standardized values of z_tem_emp_rate", size(small) color(gs5))
      Attached Files

      Comment


      • #4
        Wow.....¡¡

        That's fantastic.

        Many thanks, Andrew and Justin, for such good suggestions. They are both really valuable.

        May I ask, Andrew, what's the role of 'inlist' in your suggestion? I have checked, but it's neither an option of 'xtline' or 'overlay'. And why do you generate this variable 'lastob'?

        But I have replicated both examples with my own data, and they work wonderfully....¡

        Many thanks again for your help

        Luis

        Comment


        • #5
          May I ask, Andrew, what's the role of 'inlist' in your suggestion?
          I am just selecting two regions, i.e., 1 and 6 so that I don't end up with the messy graph in #1. As you can see, my graph has only 2 lines. When forming your groups, you can type

          Code:
          lab list ccaal
          which will give you the following:

          Code:
          ccaal:
                     1 Andaluc�a
                     2 Arag�n
                     3 Asturias
                     4 Baleares
                     5 Canarias
                     6 Cantabria
                     7 Castilla-Le�n
                     8 Castilla-La Mancha
                     9 Catalu�a
                    10 Comunidad Valenciana
                    11 Extremadura
                    12 Galicia
                    13 Madrid
                    14 Murcia
                    15 Navarra
                    16 Pa�s Vasco
                    17 Rioja
                    18 Ceuta y Melilla
          Thus, if you want a group including Cantabria, Galicia, Madrid and Rioja, you can specify the group as

          Code:
          if inlist(ccaal, 6, 12, 13, 17)
          And why do you generate this variable 'lastob'?
          I want the region name to appear at the last time-point. So I create a scatter plot of the last time-points for the regions (using the addplot() option), make the markers invisible (mcolor(none)) but include a marker label using the string variable that I created earlier (mlab(scaa)). So your region names are just labels of some invisible markers.
          Last edited by Andrew Musau; 11 Jul 2019, 09:21.

          Comment


          • #6
            Very clear, Andrew....¡

            Many thanks

            Luis

            Comment

            Working...
            X