Announcement

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

  • over time per country graph

    I am working with panel data. Panel is consist of 170 countries and time period 1970 to 2020. I want to gragh that show how wages are change over the time due to change of policies for every country. Each country show separate in line. option to diagram or map


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str87 country double(year Medinc) float smhc
    "Abkhazia"    2015 . .
    "Afghanistan" 1971 . .
    "Afghanistan" 1972 . .
    "Afghanistan" 1973 . .
    "Afghanistan" 1974 . .
    "Afghanistan" 1975 . .
    "Afghanistan" 1976 . .
    "Afghanistan" 1977 . .
    "Afghanistan" 1978 . .
    "Afghanistan" 1979 . .
    "Afghanistan" 1980 . .
    "Afghanistan" 1981 . .
    "Afghanistan" 1982 . .
    "Afghanistan" 1983 . .
    "Afghanistan" 1984 . .
    "Afghanistan" 1985 . .
    "Afghanistan" 1986 . .
    "Afghanistan" 1987 . .
    "Afghanistan" 1988 . .
    "Afghanistan" 1989 . .
    "Afghanistan" 1990 . .
    "Afghanistan" 1991 . .
    "Afghanistan" 1992 . .
    "Afghanistan" 1993 . .
    "Afghanistan" 1994 . .
    "Afghanistan" 1995 . .
    "Afghanistan" 1996 . .
    "Afghanistan" 1997 . .
    "Afghanistan" 1998 . .
    "Afghanistan" 1999 . .
    "Afghanistan" 2000 . .
    "Afghanistan" 2001 . .
    "Afghanistan" 2002 . .
    "Afghanistan" 2003 . .
    "Afghanistan" 2004 . .
    "Afghanistan" 2005 . .
    "Afghanistan" 2006 . .
    "Afghanistan" 2007 . .
    "Afghanistan" 2008 . .
    "Afghanistan" 2009 . .
    "Afghanistan" 2010 . .
    "Afghanistan" 2011 . .
    "Afghanistan" 2012 . .
    "Afghanistan" 2013 . .
    "Afghanistan" 2014 . .
    "Afghanistan" 2015 . .
    "Afghanistan" 2016 . .
    "Afghanistan" 2017 . .
    "Afghanistan" 2018 . .
    "Afghanistan" 2019 . .
    "Afghanistan" 2020 . .
    "Afghanistan" 2021 . .
    "Africa"      1971 . .
    "Africa"      1972 . .
    "Africa"      1973 . .
    "Africa"      1974 . .
    "Africa"      1975 . .
    "Africa"      1976 . .
    "Africa"      1977 . .
    "Africa"      1978 . .
    "Africa"      1979 . .
    "Africa"      1980 . .
    "Africa"      1981 . .
    "Africa"      1982 . .
    "Africa"      1983 . .
    "Africa"      1984 . .
    "Africa"      1985 . .
    "Africa"      1986 . .
    "Africa"      1987 . .
    "Africa"      1988 . .
    "Africa"      1989 . .
    "Africa"      1990 . .
    "Africa"      1991 . .
    "Africa"      1992 . .
    "Africa"      1993 . .
    "Africa"      1994 . .
    "Africa"      1995 . .
    "Africa"      1996 . .
    "Africa"      1997 . .
    "Africa"      1998 . .
    "Africa"      1999 . .
    "Africa"      2000 . .
    "Africa"      2001 . .
    "Africa"      2002 . .
    "Africa"      2003 . .
    "Africa"      2004 . .
    "Africa"      2005 . .
    "Africa"      2006 . .
    "Africa"      2007 . .
    "Africa"      2008 . .
    "Africa"      2009 . .
    "Africa"      2010 . .
    "Africa"      2011 . .
    "Africa"      2012 . .
    "Africa"      2013 . .
    "Africa"      2014 . .
    "Africa"      2015 . .
    "Africa"      2016 . .
    "Africa"      2017 . .
    "Africa"      2018 . .
    end
    ------------------ copy up to and including the previous line ------------------


  • #2
    Code:
    encode country, gen(n_country)
    xtset n_country year
    xtline wages, overlay
    will do what you ask. (Replace wages by the name of your actual wages variable.) But you probably won't be happy with the results. With a large number of countries, the lines will likely overlap in ways that create a tangled mess that is impossible to understand. Moreover, there is a huge discrepancy between wages in places like Afghanistan and, say, France or the USA. Putting all the lines on one graph will crush the low-income countries' lines down to the bottom of the graph and the variation over time in those wages will be difficult or impossible to see. You would likely be better off doing a separate graph for each country (which you can do by omitting the -overlay- option), or perhaps collecting the countries into small groups that are relatively similar in income levels and having a separate graph for each group.

    Comment


    • #3
      Actually, this challange calls for the alternative Stata visualization better known as ridgeline plots or joy plots.
      Here is the link to a post about it at the statalist.

      Note that the user community contributed package joyplot was published by Asjad Naqvi and can be installed from the ssc server:
      Code:
      ssc install joyplot , replace
      as well as from his github page where many examples can be found.

      Another user community contributed package joy_plot was published by Fernando Rios-Avila and also can be installed from the ssc server:
      Code:
      ssc install joy_plot , replace
      which offers additional functionality to create violin plots.

      For those who wonder about the use of the phrase joy plot, more on that can be found at a web page written by Claus Wilke.
      http://publicationslist.org/eric.melse

      Comment


      • #4
        There are already two good answers to your question, and further solutions are available.

        The situation may not be quite as dire as imagined if you have many countries or equivalent with missing values like Afghanistan and Africa.

        I'd say that it's given that log scale will help.

        fabplot
        from the Stata Journal offers some flexibility. Search the forum for mentions.

        Comment


        • #5
          I would like graph like this. It is nearly as Ercmelse recommand, but problem I am using stata 13 and it can be on stata 15 or up version. Secondaly , I need two variable trend in one gragh wage and smhc. Can it possible in stata 13. Thanks
          Attached Files
          Last edited by Shahla Akram; 10 Sep 2022, 04:00.

          Comment


          • #6
            Thanks Nick I have many missing value as well as unblnaced panel. Please can you explain how log value help. I listen this from you this concept is not known with me.

            Comment


            • #7
              after using this

              joyplot socMob year, over(country) lines bwid(0.5) color(CET C1) alpha(90) ///
              lc(black) lw(0.2) ///xlabel(`xmin'(60)`xmax') off(-30) ///
              ylabc(black) ///
              xtitle("Year") ytitle("Countries") ///
              title("{fontface Arial Bold:My joyplot}") subtitle("a subtitle here", color(black)) ///
              note("Some text here", size(vsmall))

              I get this graph that is not clear
              please how can i see alll country clearly
              Attached Files
              Last edited by Shahla Akram; 19 Sep 2022, 08:10.

              Comment


              • #8
                Shahla Akram you said you have a panel of 170 countries. It will never be possible to see them clearly on one plot. Choose about 10-20 countries at a time and then make something like 10 plots. Better still, pick a few important countries that you want to plot.
                Last edited by Hemanshu Kumar; 19 Sep 2022, 10:11.

                Comment

                Working...
                X