Announcement

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

  • How to calculate the marginal effect of X1 in the equation? How to write stata commands?

    After evaluating the time invariant variables using the xtseqreg command (equation is ln(y)=b0+b1X1+b2(X1)^2+b3*X1*X2+other time variable), how do I find ∂y/∂X1 with the manual setting command? What is Stata's command to find the marginal effect and elasticity?

  • #2
    Assuming you correctly coded your -xtseqreg- command as
    Code:
    xtseqreg ln_y c.X1##c.X1 c.X1#c.X2 // + other time variable
    you can run
    Code:
    margins, dydx(X1) // MARGINAL EFFECT OF X1
    margins, eyex(X1) // ELASTICITY
    Very important: the coding of the -xtseqreg- command must use factor variables appropriately. If you instead calculated a separate variable for X12 and a separate variable for X1*X2, then -margins- will give you incorrect answers, because it will not know that these variables are actually related to X1.

    I should also note that -xtseqreg- is not an official Stata command. I do not know it, and so I can't be sure that it supports factor-variable notation. As the help file shows it was written in 2019 by Sebastian Kripfganz, I strongly suspect it does. But if it doesn't, then you can't use -margins- after it. I would not know how to calculate marginal effects or elasticities after this estimator "by hand," so I hope you can use -margins-.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Assuming you correctly coded your -xtseqreg- command as
      Code:
      xtseqreg ln_y c.X1##c.X1 c.X1#c.X2 // + other time variable
      you can run
      Code:
      margins, dydx(X1) // MARGINAL EFFECT OF X1
      margins, eyex(X1) // ELASTICITY
      Very important: the coding of the -xtseqreg- command must use factor variables appropriately. If you instead calculated a separate variable for X12 and a separate variable for X1*X2, then -margins- will give you incorrect answers, because it will not know that these variables are actually related to X1.

      I should also note that -xtseqreg- is not an official Stata command. I do not know it, and so I can't be sure that it supports factor-variable notation. As the help file shows it was written in 2019 by Sebastian Kripfganz, I strongly suspect it does. But if it doesn't, then you can't use -margins- after it. I would not know how to calculate marginal effects or elasticities after this estimator "by hand," so I hope you can use -margins-.
      Thank you very much for your reply, but the xtseqreg command cannot use c.X1##c.X1 c.X1#c.X2. Do you have any other solutions?

      Comment


      • #4
        You can use do manual estimation (see any textbook on how to estimate marginal effects) and use lincom to get the right numbers.
        Or use -f_able- from SSC

        Comment


        • #5
          Originally posted by FernandoRios View Post
          You can use do manual estimation (see any textbook on how to estimate marginal effects) and use lincom to get the right numbers.
          Or use -f_able- from SSC
          Thank you for your reply. Is there any specific operation method?

          Comment

          Working...
          X