Announcement

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

  • calculating Growth rates with a gap of 3 years in a panel data

    Dear statlist,

    I am working on a panel data set and need to calculate growth rates of each panel ID showed in my data as D_ID. i want to calculate growth rate from 2008 to 2010, 2011 to 2013 and 2014 to 2016 for each panel ID.
    The data is of the following form please help me out in calculating these growth rates. Here D_ID is panel ID and Hel_hi_hsnt is the variable for which i need to calculate growth rate. a growth rate from 2008-2010 should give a single value (AS SHOWN UNDER GROWTH WHICH IS CALCULATED MANUALLY)
    d_id year hel_hi_hsnt Growth
    1 2008 9
    1 2009 9
    1 2010 9 0
    1 2011 9
    1 2012 9
    1 2013 9 0
    1 2014 9
    1 2015 9
    1 2016 9 0
    2 2008 9
    2 2009 9
    2 2010 9 0
    2 2011 9
    2 2012 8
    2 2013 8 -12.5
    2 2014 8
    2 2015 8
    2 2016 8
    3 2008 1
    3 2009 1
    3 2010 1
    3 2011 1
    3 2012 1
    3 2013 1
    3 2014 1
    3 2015 1
    3 2016 1
    end
    lOOKING FORWARD FOR YOUR HELP, THANKS IN ADVANCE.

  • #2
    Code:
    xtset d_id year 
    bysort d_id (year): gen growth = 100 * (hel_hi_hsnt - l2.hel_hi_hsnt) / l2.hel_hi_hsnt if year == 2010 | year == 2013 | year == 2016
    Hope that helps.

    Comment


    • #3
      Please visit FAQ Advice #12 (your data example needs some surgery before it can be used) and #6 (is nas nab your full real name?). I have trouble with -12.5 as a result; otherwise this may help.


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input byte d_id int year byte hel_hi_hsnt double Growth
      1 2008 9     .
      1 2009 9     .
      1 2010 9     0
      1 2011 9     .
      1 2012 9     .
      1 2013 9     0
      1 2014 9     .
      1 2015 9     .
      1 2016 9     0
      2 2008 9     .
      2 2009 9     .
      2 2010 9     0
      2 2011 9     .
      2 2012 8     .
      2 2013 8 -12.5
      2 2014 8     .
      2 2015 8     .
      2 2016 8     .
      3 2008 1     .
      3 2009 1     .
      3 2010 1     .
      3 2011 1     .
      3 2012 1     .
      3 2013 1     .
      3 2014 1     .
      3 2015 1     .
      3 2016 1     .
      end
      
      
      tsset d_id year 
      gen wanted = 100 * (hel_hi_hsnt - L2.hel_hi_hsnt) / L2.hel_hi_hsnt if inlist(year, 2010, 2013, 2016)
      
      list, sepby(d_id)
      
           +---------------------------------------------+
           | d_id   year   hel_hi~t   Growth      wanted |
           |---------------------------------------------|
        1. |    1   2008          9        .           . |
        2. |    1   2009          9        .           . |
        3. |    1   2010          9        0           0 |
        4. |    1   2011          9        .           . |
        5. |    1   2012          9        .           . |
        6. |    1   2013          9        0           0 |
        7. |    1   2014          9        .           . |
        8. |    1   2015          9        .           . |
        9. |    1   2016          9        0           0 |
           |---------------------------------------------|
       10. |    2   2008          9        .           . |
       11. |    2   2009          9        .           . |
       12. |    2   2010          9        0           0 |
       13. |    2   2011          9        .           . |
       14. |    2   2012          8        .           . |
       15. |    2   2013          8    -12.5   -11.11111 |
       16. |    2   2014          8        .           . |
       17. |    2   2015          8        .           . |
       18. |    2   2016          8        .           0 |
           |---------------------------------------------|
       19. |    3   2008          1        .           . |
       20. |    3   2009          1        .           . |
       21. |    3   2010          1        .           0 |
       22. |    3   2011          1        .           . |
       23. |    3   2012          1        .           . |
       24. |    3   2013          1        .           0 |
       25. |    3   2014          1        .           . |
       26. |    3   2015          1        .           . |
       27. |    3   2016          1        .           0 |
           +---------------------------------------------+

      Comment


      • #4
        thanks Nick it really nice of your. i got that

        Comment


        • #5
          Thanks for the thanks, but the point about FAQ Advice #6 is still an open question.

          Comment


          • #6
            I have asked STATA list Forum administrator to change...

            Comment

            Working...
            X