Announcement

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

  • First Difference Regression

    Hi,
    I'm looking for the right command to run first difference regression and have found it. I found several way to run first difference regression:
    1. reshape to wide and create new variable using
    Code:
    g new_var= old_var2-old_var1
    . Then run the regression
    2.
    Code:
    reg d.dependent_var d.independent, nocons
    My data is two years panel data in 2007 and 2014. I have my independent variable in the dummy form and i tried the first way to run first difference regression. I use this command:
    Code:
    reshape wide variable, i(id) j(year)
    g diff_dependent= dependent_variable2014 - dependent_variable2007
    g diff_independent= independent_variable2014- dependent_variable2007
    after changing the independent variable (in the form of dummy), I get results 0 and -1 (due to subtraction).
    Am I taking the right steps? Can I run first difference regression with an independent variable in the form of dumny?

  • #2
    My data is two years panel data in 2007 and 2014. I have my independent variable in the dummy form and i tried the first way to run first difference regression. I use this command:
    It does not matter that your regressor is a dummy as long as it varies for some panels between the two time periods. No need to take the differences yourself, just let Stata know that 1 time unit is equal to 7 years.


    Code:
    xtset id year, delta(7)
    reg d.dependent_var d.independent, nocons


    Note that in the case of T=2, FD regression is equivalent to fixed effects. To see this, write the differenced equation as

    $$
    \Delta y_{i} = \beta \Delta x_{i} + v_{i}
    $$

    With T=2,

    $$
    v_{i} = u_{i2} - u_{i1} = 2u_{i2} - (u_{i1} + u_{i2}) = 2(u_{i2} - \bar{u}_{i} )
    $$

    where

    $$
    \bar{u}_{i} = \frac{u_{i1} + u_{i2}}{2}
    $$

    Code:
    xtset id year, delta(7)
    reg d.dependent_var d.independent, nocons
    xtreg dependent_var independent, fe

    Comment


    • #3
      Thank you for the answer. I tried it and it works.

      Comment

      Working...
      X