Announcement

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

  • How do I show relative change on a graph?

    Hi,

    I am running a panel data of the impact of economic growth on total fertility rate. I am using panel data (n=30 and T=46) from the period 1970-2015.

    My issue is trying to show relative change in total fertility rate from two different period, first period 1970-1990 and then 1990-2015. I want to show relative change on a horizontal bar graph. Something like the image below.

    Thanks
    Click image for larger version

Name:	Screen Shot 2018-04-20 at 18.05.49.png
Views:	1
Size:	209.3 KB
ID:	1440490

  • #2
    You'll increase your chances of a helpful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Really diagnosing such data-specific problems is easier with data. You don't need all the data - just a couple of countries and the two observations would help.

    This exceeds my abilities with Stata graphs. I'd suggest you look carefully at the documentation for graphics to see if there is something there that would serve.

    Comment


    • #3
      I agree with Phil. You should have provided us with data sample as outlined in the FAQ section . Please read it through. On your question, while we do not know your data, I am wildly guessing that you need 'graph hbar' . Relative change can be plotted using regression model followed by 'margins' command. But if you simply want to plot the change between two periods (ignoring repeated measure dependencies), you can calculate the change for one period i.e. delta1 = value of 1995-value of 1980 and delta2 = value of 2015 - value of 1995. See the help file for graph hbar .

      Here is an example assuming the values have been calculated:

      Code:
      //Generate some fake data:
      
      clear
      set obs 10
      gen country = _n
      gen delta1 = runiform()*-.2
      gen delta2 = runiform()*.5
      
      loc x="country"
      forval i=1/10 {
      lab define country `i' "`x'`i'", modify
      }
      
      lab val country country
      
      
      li in 1/5, noobs clean
      
      /*Dataset*/
      
           country      delta1     delta2  
          country1   -.1726076   .3482433  
          country2   -.0705209   .4559672  
          country3    -.154408   .3397817  
          country4    -.117224   .1774708  
          country5   -.0645553    .369485
      
      ******************************************
      
      //Plot the change of two periods: delta1 is the change for each
      //country from 1980 to 1995 and delta2 from 1995 to 2015:
      
      graph hbar (asis) delta1 delta2, ///
      over(country, sort(country)) stack ///
      title( "Your title") ///
      subtitle(" ") legend(order(1 "Period1" 2 "Period2"))
      Click image for larger version

Name:	image_10668.png
Views:	1
Size:	142.4 KB
ID:	1441194
      Last edited by Roman Mostazir; 24 Apr 2018, 15:49. Reason: Help suggestion added
      Roman

      Comment

      Working...
      X