Announcement

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

  • Calculate GDP from growth rate

    Hi,

    I have GDP data for countries. But one country changed the way it calculated GDP in one period. Therefore the growth rate in this period is very high. In the following sample that would be France in the year 2002.

    input str7 country int year byte gdp
    "France" 1999 58
    "France" 2000 59
    "France" 2001 56
    "France" 2002 80
    "France" 2003 82
    "France" 2004 84
    "Germany" 2000 42
    "Germany" 2000 44
    "Germany" 2001 47
    "Germany" 2002 48
    "Germany" 2003 50
    "Germany" 2004 51
    end

    *Calculate the growth rates:

    bysort country (year): gen gdp_growth = (gdp-gdp[_n-1])/gdp[_n-1]

    country year gdp gdp_growth
    France 1999 58
    France 2000 59 .0172414
    France 2001 56 -.0508475
    France 2002 80 .4285714
    France 2003 82 .025
    France 2004 84 .0243902
    Germany 2000 42
    Germany 2000 44 .047619
    Germany 2001 47 .0681818
    Germany 2002 48 .0212766
    Germany 2003 50 .0416667
    Germany 2004 51 .02


    * Now, to make the data more plausible again, I replace the high growth rate by the average growth rate of the last two year as follows:

    bysort country (year): gen gdp_growth_av = (gdp_growth[_n-1]+gdp_growth[_n-2])/2

    replace gdp_growth = gdp_growth_av if country== "France" & year == 2002

    drop gdp_growth_av

    This gives me the following:

    country year gdp gdp_growth
    France 1999 58
    France 2000 59 .0172414
    France 2001 56 -.0508475
    France 2002 80 -.016803
    France 2003 82 .025
    France 2004 84 .0243902
    Germany 2000 42
    Germany 2000 44 .047619
    Germany 2001 47 .0681818
    Germany 2002 48 .0212766
    Germany 2003 50 .0416667
    Germany 2004 51 .02


    Now, I want to build a new GDP series for France as of 2002, i.e., take the gdp value of 2001 and use the new growth rate for 2002 to calculate a new GDP value for 2002. Then, use the new GDP value from 2002 and the growth rate for 2003 to calculate a new GDP value for 2003 and so on.

    How can I do that? Thanks in advance!


  • #2
    What you plan to do appears to lack a clear rationale and may be open to criticism, particularly given the widespread availability of a macroeconomic series such as GDP. If indeed France did make an accounting change to how it calculates its GDP, then the compilers of this series are smart enough to figure this out and make the appropriate adjustment (either prospectively or retrospectively). So just download GDP data from a reputable data provider. As an example, the World Bank series does not show a jump in the series for France in the year 2002.

    Code:
    *DOWNLOAD SERIES AND RESHAPE
    copy "https://api.worldbank.org/v2/en/indicator/NY.GDP.MKTP.KD?downloadformat=csv" API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.zip, replace
    unzipfile API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.zip, replace
    import delimited "API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.csv",varnames(1) encoding(UTF-8) rowrange(6) clear
    rename (v5-v65) gdp#, addnumber(1960)
    rename datasource country
    keep country gdp*
    reshape long gdp, i(country) j(year)
    
    *GRAPH GDP FOR FRANCE 1960-2020
    set scheme s1mono
    tw line gdp year if country=="France", sort xline(2002) ylab("") xtitle("") ytitle("") xlab(1960(5)1995 2002 2010(5) 2020) title(GDP France 1960-2020)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	17.5 KB
ID:	1710417

    Comment


    • #3
      Well, I thought this forum was about getting answers to Stata questions. I just came up with the France example because I had used this same example before and did not see a need for using actual data. But as you started a discussion about what makes economic sense: We actually do observe this one period huge hike in the growth rate of Ireland's GDP in the first quarter of 2015 -- in data coming from reputable data providers. However, it actually does not seem to come from a change in accounting standards, but from a taxation change attracting a huge increase in intangible assets (https://www.oecd.org/sdd/na/Irish-GD...-2015-OECD.pdf). Now, this high growth rate in 2015q1 apparently does not reflect an equivalent growth in the underlying economic activity. Therefore, I would like to "clean" my data from it. The idea of doing it the way I explained above came from a recent AEJ: Macro article, who did it this way. So I would be thankful if anyone could explain to me, how to calculate absolute values succesively from an initial value and growth rates.


      Comment


      • #4
        Originally posted by Johanna Krenz View Post
        Well, I thought this forum was about getting answers to Stata questions.
        It is the Stata forum, yes - but context is always needed. Therefore, if an approach does not make sense, I personally would not oblige to volunteer code.

        We actually do observe this one period huge hike in the growth rate of Ireland's GDP in the first quarter of 2015 -- in data coming from reputable data providers. However, it actually does not seem to come from a change in accounting standards, but from a taxation change attracting a huge increase in intangible assets (https://www.oecd.org/sdd/na/Irish-GD...-2015-OECD.pdf). Now, this high growth rate in 2015q1 apparently does not reflect an equivalent growth in the underlying economic activity. Therefore, I would like to "clean" my data from it. The idea of doing it the way I explained above came from a recent AEJ: Macro article, who did it this way. So I would be thankful if anyone could explain to me, how to calculate absolute values succesively from an initial value and growth rates.
        This jump is indeed observed for Ireland in 2015. There is no complication in adjusting the GDP as you request, just take the value in 2014 and multiply by (1+average growth rate for 2013 and 2014). Then for subsequent years, multiply the previous year's GDP by (1+existing growth rate) to get that year's GDP.

        Code:
        *DOWNLOAD SERIES AND RESHAPE
        copy "https://api.worldbank.org/v2/en/indicator/NY.GDP.MKTP.KD?downloadformat=csv" API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.zip, replace
        unzipfile API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.zip, replace
        import delimited "API_NY.GDP.MKTP.KD_DS2_en_csv_v2_5358444.csv",varnames(1) encoding(UTF-8) rowrange(6) clear
        rename (v5-v67) gdp#, addnumber(1960)
        rename datasource country
        keep country gdp*
        reshape long gdp, i(country) j(year)
        
        *ADJUST GDP + GRAPH FOR IRELAND 1960-2022
        set scheme s1mono
        tw line gdp year if country=="Ireland", sort xline(2015) ylab("") xtitle("") ytitle("") xlab(1960(10)2000 2015) title(GDP Ireland 1960-2022) saving(gr1, replace)
        encode country, gen(countryid)
        xtset countryid year
        gen lngdp= ln(gdp)
        gen growth=D.lngdp
        egen avgrowth= mean(cond(inrange(year, 2013, 2014), growth, .)) if country=="Ireland"
        replace growth= avgrowth if year==2015 & country=="Ireland"
        gen double newgdp= gdp if country=="Ireland" & year<2015
        replace newgdp=L.newgdp*(1+growth) if country=="Ireland" & year>=2015
        replace newgdp= gdp if missing(newgdp)
        tw line newgdp year if country=="Ireland", sort xline(2015) ylab("") xtitle("") ytitle("") xlab(1960(10)2000 2015) title(Revised GDP Ireland 1960-2022) saving(gr2, replace)
        gr combine gr1.gph gr2.gph
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	18.1 KB
ID:	1710464

        Last edited by Andrew Musau; 19 Apr 2023, 10:38.

        Comment


        • #5
          Thank you!

          Comment

          Working...
          X