Announcement

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

  • Adding lagged independent variable into fixed-effect model when the T is large

    My indepvar is trading volume(V).
    I use daily data for ten years.
    Now I want to add the lagged trading volume (VL) as an explainable variable.
    the model is V=a+bPRICE+mSIZE+nVL
    Can the command be
    xtreg V PRICE SIZE VL, fe



  • #2
    Yes. Actually, you don't have to create a separate variable for lagged trading volume. Assuming you have already -xtset panel_id date-, you can do this:

    Code:
    xtreg V PRICE SIZE l1.V, fe

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Yes. Actually, you don't have to create a separate variable for lagged trading volume. Assuming you have already -xtset panel_id date-, you can do this:

      Code:
      xtreg V PRICE SIZE l1.V, fe
      Thank you very very much!

      Comment


      • #4
        Leah - to add to Clyde's comment - you should know that a lagged dv creates problems particularly with serially correlated errors (which are likely in trading volume). You may need to look into techniques other than xtreg for these.

        Comment


        • #5
          I ma using fixed effect and random effect mode, can i use lag dependent variables up to 4 lags and lag independent variables up to 4 lags for each exogenous variables in the model?

          Comment


          • #6
            The codes for lags and the leads i generated gen LnX_L2 = LnX[_n-2]
            (2 missing values generated)

            . gen LnX_L3 = LnX[_n-3]
            (3 missing values generated)

            . gen LnX_L4 = LnX[_n-4]
            (4 missing values generated)

            . gen LnG_lead1 = LnG[_n+1]
            (1 missing value generated)

            . gen LnG_lead2 = LnG[_n+2]
            (2 missing values generated)

            . gen LnG_lead3 = LnG[_n+3]
            (3 missing values generated)

            . gen LnG_lead4 = LnG[_n+4]
            (4 missing values generated)

            . gen LncommodityP_Lead1 = LncommodityP[_n+1]
            (1 missing value generated)

            . gen LncommodityP_Lead2 = LncommodityP[_n+2]
            (2 missing values generated)

            . gen LncommodityP_Lead3 = LncommodityP[_n+3]
            (3 missing values generated)

            . gen LncommodityP_Lead4 = LncommodityP[_n+4]
            (4 missing values generated)

            . gen LnX_Lead1 = LnX[_n+1]
            (1 missing value generated)

            . gen LnX_Lead2 = LnX[_n+2]
            (2 missing values generated)

            . gen LnX_Lead3 = LnX[_n+3]
            (3 missing values generated)

            . gen LnX_Lead4 = LnX[_n+4]
            (4 missing values generated)


            Comment


            • #7
              I will not comment on the appropriateness of including multiple lags in your model: it depends on the particular model, and since we have almost no occasion to work with this kind of variable in my field (epidemiology) I am not well-informed about the implications for consistency, bias, efficiency, etc. In general terms, it introduces dependence among observations which would need to be taken into account in some way. More than that, I cannot say.

              From a coding perspective, there is no reason to generate any of these variables, as the lag and lead operators (-help tsvarlist-, and also look at #2 in this thread to see an illustration of how the first lag is done) will take care of this on the fly in your model.

              Finally, if for some reason you actually do need to create these variables, the code you have shown is probably incorrect. It will be correct only if you have a single time series (not panel data), and also only if there are no gaps in your time series. Since few data sets are that clean, you should presume that the code in #6 is wrong. You can re-write it by -xtset- or -tsset-ing your data and then using the lag and lead operators mentioned in the previous paragraph. Those operators are "smart" enough not to take observations from a different unit, and also smart enough to recognize time gaps and not be tricked by them.

              Comment


              • #8
                These paper is how commodity price affect growth in sub-saharan african countries by taking account fixed effect and random effect extimator so the data is panel data model and therefore, i think to be copnsistent i model the lagged variables as independent variables and leave the dependent variables as logarithm form so that to control the problems of consistency, endogeneity problems and omitted variables biased.I alread solve the problems of missing values by interpolations of all the missing values in the models so no missing values and it is not a time series for particular countries but a panel data set for 35 countries in sub-saharan african countries so i only lagged the and lead the commodity prices(producer) and control variables i also lagged and lead it such as export, import, gross capita formation, energy used, agriculture and so on. Can i used fixed and random effect model to applied lagged independent of my variables without my dependent variables which are already in log form so those independent will be laggged the nlog of independent variables. is it possible? Thank you for your comments

                Comment


                • #9
                  . xtreg LnG LncommodityP LnX LnG_L1 LncommodityP_L1 LnX_L1 LnG_lead1 LncommodityP_Lead1 LnX_Lead1, fe

                  Fixed-effects (within) regression Number of obs = 682
                  Group variable: cc Number of groups = 36

                  R-sq: Obs per group:
                  within = 0.9989 min = 18
                  between = 0.8956 avg = 18.9
                  overall = 0.9988 max = 19

                  F(8,638) = 72259.31
                  corr(u_i, Xb) = -0.0119 Prob > F = 0.0000

                  ------------------------------------------------------------------------------------
                  LnG | Coef. Std. Err. t P>|t| [95% Conf. Interval]
                  -------------------+----------------------------------------------------------------
                  LncommodityP | .1529288 .0199916 7.65 0.000 .1136716 .192186
                  LnX | -.0035463 .0006428 -5.52 0.000 -.0048085 -.0022841
                  LnG_L1 | .5104941 .020158 25.32 0.000 .4709101 .5500782
                  LncommodityP_L1 | -.0784157 .0146156 -5.37 0.000 -.1071162 -.0497151
                  LnX_L1 | .0018151 .0004593 3.95 0.000 .0009132 .002717
                  LnG_lead1 | .4898061 .0201147 24.35 0.000 .4503071 .5293051
                  LncommodityP_Lead1 | -.0746294 .0145287 -5.14 0.000 -.1031593 -.0460995
                  LnX_Lead1 | .0017375 .0004634 3.75 0.000 .0008276 .0026474
                  _cons | -.0020284 .021708 -0.09 0.926 -.0446562 .0405993
                  -------------------+----------------------------------------------------------------
                  sigma_u | .00296592
                  sigma_e | .01407046
                  rho | .04254229 (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------------
                  F test that all u_i=0: F(35, 638) = 0.83 Prob > F = 0.7490

                  . estimates store Fixed

                  . xtreg LnG LncommodityP LnX LnG_L1 LncommodityP_L1 LnX_L1 LnG_lead1 LncommodityP_Lead1 LnX_Lead1, re

                  Random-effects GLS regression Number of obs = 682
                  Group variable: cc Number of groups = 36

                  R-sq: Obs per group:
                  within = 0.9989 min = 18
                  between = 0.8989 avg = 18.9
                  overall = 0.9988 max = 19

                  Wald chi2(8) = 583438.09
                  corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000

                  ------------------------------------------------------------------------------------
                  LnG | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                  -------------------+----------------------------------------------------------------
                  LncommodityP | .1504507 .0193795 7.76 0.000 .1124677 .1884338
                  LnX | -.0033372 .0006213 -5.37 0.000 -.004555 -.0021195
                  LnG_L1 | .5 .0195071 25.63 0.000 .4617668 .5382332
                  LncommodityP_L1 | -.0752254 .014123 -5.33 0.000 -.102906 -.0475447
                  LnX_L1 | .0016686 .0004453 3.75 0.000 .0007958 .0025414
                  LnG_lead1 | .5 .0194635 25.69 0.000 .4618522 .5381478
                  LncommodityP_Lead1 | -.0752254 .0140667 -5.35 0.000 -.1027957 -.0476551
                  LnX_Lead1 | .0016686 .0004468 3.73 0.000 .0007929 .0025443
                  _cons | -2.75e-12 .0215946 -0.00 1.000 -.0423246 .0423246
                  -------------------+----------------------------------------------------------------
                  sigma_u | 0
                  sigma_e | .01407046
                  rho | 0 (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------------

                  . estimates store Random

                  . hausman Fixed .

                  ---- Coefficients ----
                  | (b) (B) (b-B) sqrt(diag(V_b-V_B))
                  | Fixed Random Difference S.E.
                  -------------+----------------------------------------------------------------
                  LncommodityP | .1529288 .1504507 .0024781 .004909
                  LnX | -.0035463 -.0033372 -.0002091 .0001648
                  LnG_L1 | .5104941 .5 .0104941 .0050811
                  Lncommodi~L1 | -.0784157 -.0752254 -.0031903 .0037625
                  LnX_L1 | .0018151 .0016686 .0001465 .0001124
                  LnG_lead1 | .4898061 .5 -.0101939 .0050766
                  Lncommodi~d1 | -.0746294 -.0752254 .000596 .0036347
                  LnX_Lead1 | .0017375 .0016686 .0000689 .0001228
                  ------------------------------------------------------------------------------
                  b = consistent under Ho and Ha; obtained from xtreg
                  B = inconsistent under Ha, efficient under Ho; obtained from xtreg

                  Test: Ho: difference in coefficients not systematic

                  chi2(8) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                  = 8.32
                  Prob>chi2 = 0.4029

                  .

                  Comment


                  • #10
                    This is the results obtained from stata

                    Comment

                    Working...
                    X