Announcement

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

  • Number of LAG&LEAD coefficients

    Hi Statalist users,

    I want to estimate a model to derive lag/lead effects.

    I have manually created LAG variables:
    Code:
    by nitem: gen lag_price_1=price[_n-1] if week==week[_n-1]+1
    and then always replace the numbers for each lag

    ThenI have set up my equation like this:

    Code:
    xtreg log_sales log_price_comp log_price sale_obs_1 sale_obs_3 sale_obs_2 sale_obs_4 sale_obs_0  lag_price_1 lag_price_2 lag_price_3 lag_price_4 lag_price_5 lag_price_6 lag_price_7 , fe
    
    outreg2 using lag_price.doc, replace ctitle(Model_Price Lag)
    estimates store  price_LAG
    Afterwards I wanted to test the number of neccesary lag/leads with likelihood ratio test

    Code:
    lrtest price_LAG|price_Lead, stats dir
    (MY price_Lead is similiarily created)

    Unfortunately I always receive this error:

    df(unrestricted) = df(restricted) = 13

    Now I have two questions:
    -Is my way by manually adding new lag/lead variables efficient or is there a shortcut to streamline this process?
    -How do I implement likelihood ratio test? And how can I derive from this test the best number of lead or lag variables?

  • #2
    Dear Andreas,
    Is my way by manually adding new lag/lead variables efficient or is there a shortcut to streamline this process?
    There is a shortcut, but it requieres well ordered dataset : The command L1.varname gives the first lag of the variable, (and so on with L2, L3); similar lead (forward) variable could be generated with F1.varname.
    However, before that you need to specify the individual and time units, with the tsset command (for time series) or xtset (for panel variables).
    Once your panel properly announced, you don't need to create the lag and lead variables, just announce them in your regression
    Code:
    xtreg log_sales log_price L1.log_price L2.log_price F1.log_price F2.log_price .....
    I didn't really understood what you trying to do with the LR test. It seems like you comparing your lag and lead model. Such comparision will not give you the best number of lead or lag variable. You'll have that comparing the results of Lag model with one lag VS two lag.
    However, I don't know your dataset, but it seems to me that adding up to 7 lags of the same price, will lead to high autocorrelation in your model. Hence the best model might not be the one with all laged/lead variables.

    Comment


    • #3
      Dear Charlie,

      As you mentioned above that to create lag variables in a shortcut way requires well ordered dataset, could you please explain more about the requirement for dataset?

      Comment

      Working...
      X