Announcement

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

  • Command to turn Economic growth averaged in 5 year periods

    Hello,

    I have a panel dataset that consists of 67 countries and I want to compute economic growth averaged in 5 year periods. I have data from 1989-2012 and through averaging I aim to get 5 observations per country such as 1989-1993 (1 obs), 1994-1998 (1 obs) ... and the last one consists only of 2009-2012.

    So far I have tried manually to get the economic growth for 5 year periods as follows:
    1) take logs of real GDP per capita
    2) ln(1993)-ln(1989) divided with 4; ln(1998)-ln(1993) divided with 5 , ln(2003)-ln(1998) divided with 5... and for the last ln(2012) - ln(2008) divided with 4.

    I have two questions:
    1) Is this the correct way to compute growth averaged in 5 year periods?
    2) what is the state command/commands that can give me the averaged data for economic growth?

    Thank you!


  • #2
    You should average first before taking logs. Otherwise, you will have a geometric average. Either the -ceil()- or -floor()- function can be used for this. The growth rate can be approximated by the difference of logarithms.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte id float(year gdp)
    1 1989 3.92
    1 1990 3.21
    1 1991 3.74
    1 1992 3.88
    1 1993 3.14
    1 1994 3.01
    1 1995 3.55
    1 1996 3.32
    1 1997 3.98
    1 1998 3.08
    1 1999 3.32
    1 2000 3.75
    1 2001 4.15
    1 2002 4.02
    1 2003 4.23
    1 2004 4.76
    1 2005 4.29
    1 2006 4.67
    1 2007 4.04
    2 1989  3.3
    2 1990 3.97
    2 1991 3.98
    2 1992 3.65
    2 1993 3.02
    2 1994  3.4
    2 1995  3.6
    2 1996 3.57
    2 1997 3.69
    2 1998 3.19
    2 1999 3.10
    2 2000 3.73
    2 2001 3.35
    2 2002 3.95
    2 2003 3.27
    2 2004 3.48
    2 2005 3.84
    2 2006 3.38
    2 2007 3.06
    3 1989 2.14
    3 1990 2.13
    3 1991  2.4
    3 1992 2.76
    3 1993  2.6
    3 1994 2.17
    3 1995 2.928
    3 1996 2.63
    3 1997 2.62
    3 1998 2.11
    3 1999 2.48
    3 2000    2.1
    3 2001 2.55
    3 2002 2.93
    3 2003 2.16
    3 2004 2.27
    3 2005 2.2
    3 2006 2.76
    4 1989 2.27
    4 1990 2.29
    4 1991 2.63
    4 1992 2.07
    4 1993 2.62
    4 1994 2.13
    4 1995 2.19
    4 1996 2.37
    4 1997 2.95
    4 1998 2.76
    4 1999 2.18
    4 2000 2.79
    4 2001   2.4
    4 2002 2.86
    4 2003 2.12
    end
    
    
    bys id (year): gen time=_n
    gen period= ceil(time/5)
    collapse gdp, by(id period)
    gen lngdp= ln(gdp)
    bys id (period): gen g1= (gdp/gdp[_n-1])-1
    xtset id period
    gen g2= lngdp-l.lngdp
    Res.:

    Code:
    . sort id period
    
    . l, sepby(id)
    
         +---------------------------------------------------------+
         | id   period      gdp      lngdp          g1          g2 |
         |---------------------------------------------------------|
      1. |  1        1    3.578   1.274804           .           . |
      2. |  1        2    3.388    1.22024   -.0531023   -.0545642 |
      3. |  1        3    3.894   1.359437    .1493507    .1391971 |
      4. |  1        4     4.44   1.490654    .1402157    .1312175 |
         |---------------------------------------------------------|
      5. |  2        1    3.584   1.276479           .           . |
      6. |  2        2     3.49   1.249902   -.0262277   -.0265777 |
      7. |  2        3     3.48   1.247032   -.0028653   -.0028695 |
      8. |  2        4     3.44   1.235471   -.0114942   -.0115608 |
         |---------------------------------------------------------|
      9. |  3        1    2.406   .8779657           .           . |
     10. |  3        2   2.4916   .9129251    .0355777    .0349594 |
     11. |  3        3    2.444    .893636   -.0191042    -.019289 |
     12. |  3        4     2.41   .8796268   -.0139116   -.0140092 |
         |---------------------------------------------------------|
     13. |  4        1    2.376   .8654184           .           . |
     14. |  4        2     2.48   .9082586    .0437711    .0428402 |
     15. |  4        3     2.47   .9042181   -.0040323   -.0040404 |
         +---------------------------------------------------------+
    
    .

    Comment


    • #3
      Thank you very much! Can you please explain what is g1 exactly?

      bys id (period): gen g1= (gdp/gdp[_n-1])-1 I did not entirely understand the purpose of this command.

      Comment


      • #4
        You define the growth rate of GDP as the percentage change in GDP, year on year. Maybe you are more accustomed to seeing this as:

        $$g_{GDP} = \frac{GDP_{t}- GDP_{t-1}}{GDP_{t-1}} \;\; \text{(Eq. 1)}$$

        With a common denominator, we can write the right hand side of Eq. 1 as

        $$g_{GDP} = \frac{GDP_{t}}{GDP_{t-1}} - \frac{GDP_{t-1}}{GDP_{t-1}} = \frac{GDP_{t}}{GDP_{t-1}} - 1 \;\; \text{(Eq. 2)}$$

        So the code is Eq. 2's representation of the growth rate of GDP.

        Comment

        Working...
        X