Announcement

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

  • Cumulative inflation

    Hi! I have a panel data with prices (p) item and time(t). I would like to compute the cumulative inflation. I.e.:
    t p item p/p[t-1]
    1 10 apple .
    2 12 apple 1.2
    3 10 apple 0.833
    4 15 apple 1.5
    1 20 orange .
    3 21 orange 1.05
    4 20 orange 0.952
    5 20 orange 1
    6 20 orange 1
    that implies for apples the cumulative inflation was: 1.2 for t=2, 1 for t=3 and 1.5 for t=4 and for oranges: 1.05 for t=3 and then 1 until the end of the period. How can I compute that with stata.

    For the last column (the monthly inflation) I have:

    Code:
    gen price_change_per = price/price[_n-1] if item==item[_n-1]
    but I cannot come up with the doce for the cumulative one? I'm concerned not only for the final value of the cumulative inflation (1.5 for apples and 1 for oranges) but also for the evolution it has.

    Best and thanks a lot!

  • #2
    Is that what you want?
    Code:
    . sort item t
    
    . by item: gen ratio = p/p[_n-1]
    (2 missing values generated)
    
    . list, sep(0)
    
         +-----------------------------------+
         | t    p     item   ppt1      ratio |
         |-----------------------------------|
      1. | 1   10    apple      .          . |
      2. | 2   12    apple    1.2        1.2 |
      3. | 3   10    apple   .833   .8333333 |
      4. | 4   15    apple    1.5        1.5 |
      5. | 1   20   orange      .          . |
      6. | 3   21   orange   1.05       1.05 |
      7. | 4   20   orange   .952    .952381 |
      8. | 5   20   orange      1          1 |
      9. | 6   20   orange      1          1 |
         +-----------------------------------+

    Comment

    Working...
    X