Announcement

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

  • Cumulative rate of GDP growth per countries

    Hello,

    I have been working on panel data where I have different values of GDP growth (annual %), poverty headcount and other variables for different countries from 1991-2017. I want to estimate the cumulative rate of GDP growth per countries from 1991-2017. The formula for this calculation is given by:

    (1+G)= (1+g1)(1+g2)(1+g3)(1+g4)+........(1+gt)
    where G is the cumulative growth rate of GDP growth and, g1, g2, g3, g4 and gt are the GDP growth rate for countries in different years.

    I had extracted some parts of the data which go from 1991 to 2017 and the data looks this way in Stata:

    clear all
    input str10 country year gdpgrowth
    country year GDP
    Albania 1996 0.091
    Albania 2002 0.0423
    Albania 2005 0.0572
    Albania 2008 0.0376
    Albania 2012 0.0141
    Algeria 1995 0.0379
    Algeria 2011 0.0289
    Argentina 1991 0.1266
    Argentina 1992 0.1194
    Argentina 1993 0.059
    Argentina 1994 0.0583
    Argentina 1995 -0.0285
    Argentina 1996 0.055
    Argentina 1997 0.081
    Argentina 1998 0.0385
    Argentina 1999 -0.033
    Argentina 2000 -0.0078
    Argentina 2001 -0.044
    Argentina 2002 -0.1089
    Argentina 2003 0.0883
    Argentina 2004 0.0902
    Argentina 2005 0.088
    Argentina 2006 0.0804
    Argentina 2007 0.090
    Argentina 2008 0.0405
    Argentina 2009 -0.059
    Argentina 2010 0.10125

    end

    Thanks,

    Pythagore
    Last edited by Pythagore Donfouet; 13 May 2018, 11:13.

  • #2
    Well, you have a problem here. Your data have many gaps in the time series, so that the simple formula you showed does not really apply here. How do you propose to handle the missing years?

    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment


    • #3
      Thanks a lot Clyde for the advice. As you will notice below I deleted missing observations for poverty headcount variable and also for the GDP growth rate. This has created some gaps for the GDP growth rate. If we take the original data below without deleting missing observations, how can we estimate the cumulative GDP growth rate per country taking into account the first value of GDP growth rate till the last year value of GDP growth rate?

      The data can be seen as below:

      clear
      input str52 country int year double(Povertyheadcountratioat190 gdpdgrowthannual)
      "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 . 8.444163226792185
      "Afghanistan" 2004 . 1.0555557874655506
      "Afghanistan" 2005 . 11.175270241658723
      "Afghanistan" 2006 . 5.554137622575013
      "Afghanistan" 2007 . 13.740204989851335
      "Afghanistan" 2008 . 3.6113683922616815
      "Afghanistan" 2009 . 21.020648736367804
      "Afghanistan" 2010 . 8.433290481617917
      "Afghanistan" 2011 . 6.113685169422993
      "Afghanistan" 2012 . 14.43474128795242
      "Afghanistan" 2013 . 3.90057487339908
      "Afghanistan" 2014 . 2.6905219515361125
      "Afghanistan" 2015 . 1.3100403923991735
      "Afghanistan" 2016 . 2.3667119310345015
      "Afghanistan" 2017 . .
      "Albania" 1991 . -29.588997701291163
      "Albania" 1992 . -7.199999986164258
      "Albania" 1993 . 9.600000045405295
      "Albania" 1994 . 8.299999979826936
      "Albania" 1995 . 13.299999992363638
      "Albania" 1996 1.1 9.10000000771629
      "Albania" 1997 . -10.83785573565666
      "Albania" 1998 . 9.008852539954717
      "Albania" 1999 . 13.501173375433595
      "Albania" 2000 . 6.6666204988136855
      "Albania" 2001 . 7.940331424547622
      "Albania" 2002 2 4.2313710175822905
      "Albania" 2003 . 5.773490560800781
      "Albania" 2004 . 5.709556596209993
      "Albania" 2005 1.1 5.720819946785554
      "Albania" 2006 . 5.431012738529148
      "Albania" 2007 . 5.899999999807548
      "Albania" 2008 .4 3.760853683243809
      "Albania" 2009 . 3.352610242506614
      "Albania" 2010 . 3.7100577929743537
      "Albania" 2011 . 2.5501608597772787
      "Albania" 2012 1.1 1.4199675411489494
      "Albania" 2013 . 1.0007545995742078
      "Albania" 2014 . 1.7743687432366357
      "Albania" 2015 . 2.226581413764592
      "Albania" 2016 . 3.3699886115784636
      "Albania" 2017 . .
      "Algeria" 1991 . -1.200000584390537
      "Algeria" 1992 . 1.8000023010180257
      "Algeria" 1993 . -2.100000759214012
      "Algeria" 1994 . -.8999965488494865
      "Algeria" 1995 5.9 3.7999947898763793
      "Algeria" 1996 . 4.099998469755789
      "Algeria" 1997 . 1.099999937850555
      "Algeria" 1998 . 5.100003610502341
      "Algeria" 1999 . 3.2000015505953456
      "Algeria" 2000 . 3.8196784955987937
      "Algeria" 2001 . 3.0083954661371592
      "Algeria" 2002 . 5.609323189832736
      "Algeria" 2003 . 7.2018722440160445
      "Algeria" 2004 . 4.301624264364293
      "Algeria" 2005 . 5.907791268081326
      "Algeria" 2006 . 1.6844883186912796
      "Algeria" 2007 . 3.3728751543716413
      "Algeria" 2008 . 2.360134861053268
      "Algeria" 2009 . 1.6322438375223243
      "Algeria" 2010 . 3.6341453533424612
      "Algeria" 2011 .5 2.8918659946484837
      "Algeria" 2012 . 3.374768650687841
      "Algeria" 2013 . 2.7676388667711223
      "Algeria" 2014 . 3.789121211668231
      "Algeria" 2015 . 3.7634669578312554
      "Algeria" 2016 . 3.2999999997559684
      "Algeria" 2017 . .
      "American Samoa" 1991 . .
      "American Samoa" 1992 . .
      "American Samoa" 1993 . .
      "American Samoa" 1994 . .
      "American Samoa" 1995 . .
      "American Samoa" 1996 . .
      "American Samoa" 1997 . .
      "American Samoa" 1998 . .
      "American Samoa" 1999 . .
      "American Samoa" 2000 . .
      "American Samoa" 2001 . .
      "American Samoa" 2002 . .
      "American Samoa" 2003 . .8141112618724264
      "American Samoa" 2004 . .5383580080753774
      "American Samoa" 2005 . -.40160642570282334
      "American Samoa" 2006 . -4.166666666666657
      "American Samoa" 2007 . 1.9635343618513303
      "American Samoa" 2008 . -2.6134800550206165
      "American Samoa" 2009 . -4.237288135593232
      end


      Thanks again

      Pythagore

      Comment


      • #4
        Your data look very different this time around. First, you now have no internal gaps in the data for any country: once the gdpdgrowth variable is non-missing, it stays non-missing for a block of consecutive years until reaching a final year, after which it becomes missing again. Also the numbers are now a different order of magnitude and appear to be percentages rather than proportions.

        Since your original data did have internal gaps, I fear that your full data set may still have them as well, so I have made this code a bit more complicated so that it only computes compound growth over periods of consecutive years. If in your data there are countries with years "skipped over" then the calculation of G stops when it hits those gaps, and starts over from scratch when the data resume.

        This will do it:
        Code:
        assert gdpdgrowthannual >= -100
        
        gen byte mgdp = missing(gdpdgrowthannual)
        by country (year), sort: gen consecutive_block = sum(mgdp != mgdp[_n-1])
        replace consecutive_block = 0 if mgdp
        
        by country consecutive_block (year), sort: gen G = 1+gdpdgrowthannual/100 ///
            if _n == 1 & consecutive_block
        by country consecutive_block (year): replace G = G[_n-1]*(1+gdpdgrowthannual/100) ///
            if _n > 1 & consecutive_block
        replace G = 100*(G-1)

        Comment


        • #5
          Dear Professor Clyde,

          Thanks a lot. Your code perfectly works and the results are the same with what Kid suggested.

          In fact, I was also helped by Christopher Baum and I decided to share it since it will eventually help some researchers. However, it will be good to check that they are no missing years in the sequence for each country, as they would cause the computation to be incorrect.

          The code is:

          bys country: g var4= log(1+ gdpdgrowthannual)
          bys country: g Gcum = exp(sum(var4)) -1
          bys country: g Glast = Gcum if _n==_N
          by country: egen G = min(Glast)
          list G

          Thanks again to Clyde and Kit

          Comment

          Working...
          X