Announcement

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

  • Delta method for standard error in stata?

    How to use delta method to calculate standard error in stata

    Run the regression Yi=aXi+other terms.

    for example, i = product 1, product 2 and product 3
    Increase of variable Xi= 12 30 15
    sales increase Yi = 12a 30a 15a
    Product price Pi = 3 6 8

    I get sales-weighted average price/cost increase = (12a*3+30a*6+15a*8)/(12a+30a+15a)

    How can I obtain the standard error for the sales-weighted average price increase


    Thanks










  • #2
    It is a bit difficult to relate what you have written to a specific data structure, variables and models, but, off hand, it looks like you are trying to evaluate a non-linear combination of regression coefficients. If that's the case, see -help nlcom-.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      It is a bit difficult to relate what you have written to a specific data structure, variables and models, but, off hand, it looks like you are trying to evaluate a non-linear combination of regression coefficients. If that's the case, see -help nlcom-.
      Thanks for your reply. I try to nlcom to solve it. seems it has some problems. I try to explain my question clearly with a simple example.

      Data structure
      Product year price sales size ...
      product1 2001 200 20 1 ...
      product2 2001 150 14 2 ...
      product3 2001 300 30 3 ...
      product1 2002 145 16 1 ...
      product2 2002 134 14 2 ...
      product3 2002 310 29 3 ...
      -xtreg sales price

      for example, I get the slope, 0.1(_b[price])

      Use the slope, I can calculate the predicted sales, sales_hat for 2003
      year price sales_hat size
      product1 2003 160 16 1
      product1 2003 140 14 2
      product1 2003 300 30 3
      The sales-weighted average size in 2001 and 2002 can be calculated exactly from the first table.


      But I want to calculate the sales-weighted average size for 2003

      (16*1+14*2+30*3)/(16+14+30)

      Therefore, I use "nlcom" to obtain the se for this average size.

      -nlcom sum(_b[price]*price*size)/sum(_b[price]*price)

      But it doesn't work.
      Last edited by Shi Y. Yan; 06 May 2015, 09:29.

      Comment


      • #4
        OK. I think I get it now. You don't actually need to fiddle directly with the regression coefficients, because -predict- will do that all for you. You have sales and you have size as variables. So you can do this:

        Code:
        xtreg sales price
        predict sales_hat
        by product (year), sort: egen sales_weighted_total_size = total(sales_hat*size)
        by product (year), sort: egen total_sales = total(sales_hat)
        gen sales_weighted_average_size = sales_weighted_total_size/total_sales

        Comment


        • #5
          I realized just now that my previous post gives you a simpler way to calculate the sales weighted average size, but it does not address your original question about using the delta method to get the standard error of the latter. And I'm afraid I don't know the answer to it and I don't see how it would work. If I were in need of that standard error, I imagine I would probably try to get it by bootstrapping.

          Comment


          • #6
            Thanks for your relies

            Comment

            Working...
            X