Announcement

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

  • Calculating multi-period growth rate

    Hello, I am new to Stata. I'm using Stata version 14. I am working with a balanced panel data set over the period 1992 to 2013 (T = 22 and N = 528). I want to calculate multi-period growth rate between the start year (1992) and end year (2013) for all N using the following formula:

    (y_2013/y_1992)^(2013-1992) -1

    I am seeking help from Statalist for automating the formula for all N. Thank you for your kind help.

    Sincerely,
    Jobaida Behtarin
    East West University
    Dhaka, Bangladesh

  • #2
    The code for what you want depends on the layout and organization of your data. When asking for help with code, it is always best to show an example of your data, by using the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, -dataex- 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
      Dear Clyde,

      Thank you for your suggestion. My panel data looks the following:
      input int(id year) str25 upazila float light
      1 1992 "Amtali" 24.3394
      1 1993 "Amtali" 34.5811
      1 1994 "Amtali" 32.2074
      1 1995 "Amtali" 35.4693
      ..............................................

      1 2013 "Amtali" 36.495
      2 1992 "Bamna" 9.62866


      2 1993 "Bamna" 10.6162
      2 1994 "Bamna" 10.7013
      2 1995 "Bamna" 10.5978

      .............................................. 2 2013 "Bamna" 11.4378
      .................................................. ..
      .................................................. ..

      .................................................. ..
      528 1992 "Subarnachar" 49.2416
      528 1993 "Subarnachar" 62.4037
      528 1994 "Subarnachar" 74.6971
      528 1995 "Subarnachar" 96.5276
      .................................................. ..
      528 2013 "Subarnachar" 52.7121

      I would like to calculate multi-period growth for each id using the following formula:

      gen g = (light_2013 / light_1992)^(1/2013-1992)) - 1

      where light_2013 and light_1992 are the corresponding values of "light" in year 2013 and 1992, respectively. Your assistance is highly appreciated.

      Sincerely,
      Behtarin

      Comment


      • #4
        Code:
        clear*
        input int(id year) str25 upazila float light
        1 1992 "Amtali" 24.3394
        1 1993 "Amtali" 34.5811
        1 1994 "Amtali" 32.2074
        1 1995 "Amtali" 35.4693
        1 2013 "Amtali" 36.495
        2 1992 "Bamna" 9.62866
        2 1993 "Bamna" 10.6162
        2 1994 "Bamna" 10.7013
        2 1995 "Bamna" 10.5978
        2 2013 "Bamna" 11.4378
        528 1992 "Subarnachar" 49.2416
        528 1993 "Subarnachar" 62.4037
        528 1994 "Subarnachar" 74.6971
        528 1995 "Subarnachar" 96.5276
        528 2013 "Subarnachar" 52.7121
        end
        
        by id (year), sort: gen annualized_growth_rate = (light[_N]/light[1])^(1/(year[_N]-year[1])) - 1
        Note: Your formula for the growth rate is not quite correct. I have modified it in my code. I have also written the code in a more general way so that if the first year and last year are not 1992 and 2013, respectively, the code will still give a correct annualized growth rate for whatever those years happen to be. The growth rate is calculated as a proportion, not as a percent. If you want growth rates in percent, multiply these results by 100.

        In the future, when posting example data, please post the -dataex- output exactly as Stata gives it to you, without editing it. While it was easy enough to fix up what you posted to make it usable, the more helpful you are in posting, the better others will be able to help you.

        Comment


        • #5
          Thank you so much for the assistance.

          Comment

          Working...
          X