Announcement

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

  • Local problem and CAGR

    Good afternoon everyone,

    Thanks in advance to those who will take the time to read my question. I have data on the value added of several manufacturing industries (17) for several countries (9) and over a period of 24 years (1990-2014). So I have a database in the following form:

    Code:
    Bolivia - 1990 - Sector 1 - Real Value Added
    Bolivia - 1990 - Sector 2 - Real Value Added
    Bolivia - 1990 - Sector 3 - Real Value Added
    …
    Bolivia - 1991 - Sector 1 - Real Value Added
    Bolivia - 1991 - Sector 2 - Real Value Added
    Bolivia - 1991 - Sector 3 - Real Value Added
    …
    Bolivia - 1992 - Sector 1 - Real Value Added
    Bolivia - 1992 - Sector 2 - Real Value Added
    Bolivia - 1992 - Sector 3 - Real Value Added
    …
    Bolivia - 1994 - Sector 1 - Real Value Added
    Bolivia - 1994 - Sector 2 - Real Value Added
    Bolivia - 1994 - Sector 3 - Real Value Added
    For the purpose of conversion into dollars, I need to calculate the annual growth rate of my series. Logically enough, I have grouped my sectors with my countries in order to declare my database as a panel and thus use the following command:

    Code:
    gen RealVA_GR = ((RealVA_LCU - L1.RealVA_LCU)/L1.RealVA_LCU) if !missing(RealVA_LCU) 
    The code works, but I quickly realized a problem. Sometimes my years do not follow each other exactly (as in the example above) so that the growth rate for some years cannot be calculated (e.g. 1994). I do not want to "force" the estimate between 1992 and 1994 because this would obviously bias all my growth rates which are annual. I therefore decided to calculate the compound annual growth rate for all my series so that, when there is no jump between my years, I end up with my classic growth rate (1) while calculating the average annual growth rate when there are missing years (2). But this is where the problem arises. I tried to do this by using a local that would capture all the years of each of my countries, but how do I make sure that in my loop, my formula is linked to the previous value included in the local and not the year n-1 which may not match sometimes given my year jumps? I was thinking of doing something like this:

    Code:
    levelsof Years if Country==1, local (years_bolivia)
    gen RealVA_GR=.
    foreach y of local years_bolivia {
                    replace RealVA_GR = ((RealVA_LCU[Years == `y']/RealVA_LCU[Years == Last value contained in my local])^(1/(`y'- Last value contained in my local))-1) if Country==1 & Years==`y'
    }
    I can't find an answer in the documentation related to the local on Stata, that's why I'm asking. I hope I'm not disturbing unnecessarily!
    Thanks in advance!
Working...
X