Announcement

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

  • Ipolate/Epolate?

    Hello Statalist,

    I am using Stata 14. I have a dataset with over 1000 products and want calculate some price indices.
    I want to use the starting quantity of each product and use that to make some calculations. When the product is available at the starting period I can use ipolate to set the quantity for that product as quantity0. When the starting period has no quantity available this method does not work anymore. Below is a subset shown with some data

    Code:
    clear all
    input id product_id period price quantity
    1 1 1 3 4
    2 1 2 2 5
    3 1 3 3 3
    4 1 4 2 6
    5 2 1 . . 
    6 2 2 . .
    7 2 3 4 3
    8 2 4 5 2
    9 3 1 . .
    10 3 2 1 2
    11 3 3 2 5
    12 3 4 2 3
    end
    
    local start period[1]
    gen temp = quantity
    replace temp = . if period != `start'
    ipolate temp product_id, generate(quantity0)
    Question: How can I get a variable quantity0 that has a value of 4 for all periods for product_id == 1,
    a value of 3 for periods 3 and 4 for product_id == 2,
    and a value of 2 for periods 2, 3 and 4 for product_id == 3.

    Thank you in advance

  • #2
    If any interpolation makes sense here, it would be


    Code:
    ipolate quantity period, by(product_id) generate(something)
    What rule is that which yields

    4 for all periods for product_id == 1,
    3 for periods 3 and 4 for product_id == 2,
    2 for periods 2, 3 and 4 for product_id == 3.

    ?

    Comment


    • #3
      4 is the starting quantity for product_id ==1
      3 is the starting quantity for product_id ==2
      2 is the starting quantity for product_id ==3

      So I am looking for a way to get the following result:
      Code:
      quantity0
      4
      4
      4
      4
      .
      .
      3
      3
      .
      2
      2
      2

      Comment

      Working...
      X