Announcement

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

  • how to lag variables correctly in unbalanced datasset

    Hi there
    I would like to lag my firm-level and country-level variables by one year, Xi,t−1, as controls. I just use the Stata command: gen lag_x=x[_n-1] for all the controls that I need to include in my model. Is this correct or do I need to do it differently?

    thanks for your kind input.

  • #2
    Hi Saleh,

    The lag_x variables you define depend on the data being properly sorted. Moreover, the lag of the first observation for firm 2 would pick up the last value for firm 1 (assuming the data were sorted by firm then year.)

    Assuming you have a panel indexed by panelvar and timevar, start by xtset-ing your data

    Code:
    xtset panelvar timevar
    Then the regression of y on lagged x is given by

    Code:
    regress y L.x
    Devra Golbe
    Professor Emerita, Dept. of Economics
    Hunter College, CUNY

    Comment


    • #3
      Thanks prof. Devra

      Comment

      Working...
      X