Announcement

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

  • command to calculate average growth rate with 5 years interval?

    I have a panel dataset and need to take the lag of the total population with a 5-year interval so that in the end I can get the average growth rate.
    For that purpose, the command I used are:

    rename Year_ Population_growth
    gen lag1 = Population_growth[_n-1]
    gen growth_rate = (Population_growth-lag1[_n-5]/lag1[_n-5])*100

    My dataset looks something like this:

    Country_name Year Country_code Population_growth _merge
    Afghanistan 1950 4 7752.117 matched (3)
    Algeria 1951 4 7840.151 matched (3)
    Afghanistan 1952 4 8039.684 matched (3)
    Angola 1954 4 8151.316 matched (3)
    Afghanistan 1955 4 8270.992 matched (3)

    Please let me know the commands that could be used to calculate population growth and then the average growth rate of the dataset?
    Last edited by Syeda Tamseel Zahra; 09 Apr 2021, 06:44.

  • #2
    Good day,

    Can you share sample data using the -dataex-? It will allow us to understand the question much easily. The first line computed a new variable that is lagged by 1 (and I guess by 1 year, but again seeing real data would help.) As long as the data are correctly sorted by year and there were no gaps, this should be fine.

    However, I have trouble understanding the second line and what it tries to achieve. Due to the order of operation, (lag1[_n-5]/lag1[_n-5]) will be resolved first, and it will be 1 because the numerator and denominator are equal. Maybe it's meant to be:
    Code:
    gen growth_rate = ((Population_growth-lag1[_n-5])/lag1[_n-5])*100
    but I am very skeptical about how the "5-year interval" is interpreted here. First, why not just change the first line to lag by 5? Second, if it's already lagged by 1 in the first line, and now lag by another 5, it's a 6-year interval.

    So, if possible, please explain to us what the rates are in words rather than in Stata code. And if there is a formula, or an example, that'd be perfect.

    Comment


    • #3
      You should first define your dataset as a panel using xtset. This will allow you to use lead/lag operators without the potential issues of simply using the ordering of your observations (which might include gaps). Then, in order to obtain an annualized growth rate something like

      Code:
      gen growth_rate = ((population/l5.population)^(1/5))-1
      should do the trick.

      Comment


      • #4
        Hey, I apologize!
        So below is a short example of how my dataset looks like.
        Well, I tried the above-listed commands as well but it says time variable not set and also that L5 not defined.
        sr#

        34411.
        Country_name

        Vanuatu
        Year

        2083
        Country_code

        548
        Population_growth

        846.659
        _merge

        matched
        (3)
        34412. Vanuatu 2084 548 854.583 matched (3)
        34413. Vanuatu 2085 548 862.436 matched (3)
        34414. Vanuatu 2086 548 870.205 matched (3)
        34415. Vanuatu 2087 548 877.885 matched (3)

        Comment


        • #5
          Code:
          help xtset

          Comment

          Working...
          X